Recent

Author Topic: how do I shell to python a script that has GUI features  (Read 2660 times)

Michael Collier

  • Sr. Member
  • ****
  • Posts: 301
how do I shell to python a script that has GUI features
« on: January 18, 2017, 05:51:23 pm »
I'm able to open a python script in IDLE and execute with F5 (Run Module).
I'm able to write simple scripts hello_world.py and run from IDLE (F5), or DOS command prompt

Code: Pascal  [Select][+][-]
  1. python C:/temp/hello_world.py

But, I notice that if I try and run certain scripts (I'm testing with those that ship with python) in IDLE they are OK, but when I attempt to execute from windows command prompt nothing appears to happen. No errors or warnings either.

As an example I tried running
Code: Pascal  [Select][+][-]
  1. python C:/Users/mike/AppData/Local/Programs/Python/Python36-32/Lib/idlelib/tooltip.py

I tried moving into the directory containing the tooltip.py file and run from there but nothing happens.

Could someone point me in the right direction please? Maybe I'm not executing with enough parameters?

I'm hoping that if I can execute from DOS prompt, I can later try and execute from TProcess, but just doing DOS prompt would be a good start.

Thanks..

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: how do I shell to python a script that has GUI features
« Reply #1 on: January 18, 2017, 06:02:26 pm »
You have python in the PATH?

Windows, Linux?
« Last Edit: January 18, 2017, 06:14:45 pm by lainz »

Michael Collier

  • Sr. Member
  • ****
  • Posts: 301
Re: how do I shell to python a script that has GUI features
« Reply #2 on: January 18, 2017, 06:30:57 pm »
I assumed my paths were OK because I am able to execute simple scripts:

Code: Pascal  [Select][+][-]
  1. python C:/temp/hello_world.py

Here is my windows path setting for python, 2 entries, do I need more?

C:\Users\mike\AppData\Local\Programs\Python\Python36-32\Scripts\;C:\Users\mike\AppData\Local\Programs\Python\Python36-32

Michael Collier

  • Sr. Member
  • ****
  • Posts: 301
Re: how do I shell to python a script that has GUI features
« Reply #3 on: January 18, 2017, 06:41:13 pm »
It might be worth me mentioning also that the kind of scripts I'm trying to run contain code like this

Code: Pascal  [Select][+][-]
  1. if __name__ == '__main__':
  2.     from idlelib.idle_test.htest import run
  3.     run(_tooltip)

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: how do I shell to python a script that has GUI features
« Reply #4 on: January 18, 2017, 06:43:01 pm »
It works fine here, I get a GUI when I run the script you pointed. I suppose when you installed it you clicked on Add to PATH because I get the same path you described. Also I clicked on the last button that says that it fixes the limit of characters or something like that at the end of the setup.

Michael Collier

  • Sr. Member
  • ****
  • Posts: 301
Re: how do I shell to python a script that has GUI features
« Reply #5 on: January 18, 2017, 06:57:35 pm »
It suddenly started working for me too now!!?? Weird... Didn't change any paths, wondering if conflict with other windows I had open at the time (is it a gtk/widget thingy issue..?)

I'll keep an eye on it and post here If I notice a pattern for fail/success

hmm.. I did a temporary change to source of the tooltip.py to display __main__ value. Then returned the script back to its original code. It worked after that but maybe just coincidence..


 

TinyPortal © 2005-2018