Help running pythonw from a command prompt with arguments

E

Eric Ching

Can I run pythonw with a script that takes command line arguments then
launches a GUI? I try pythonw myscript.pyw -option arg (etc.) and
nothing happens. Nothing, as in I am immediately returned to the DOS
prompt.

I just started learning Python a couple of weeks ago, so please bear
with me. I have a script that(for now) uses command line arguments
then launches a window (Tk). Once I have entered the arguments and
the window is launched I do not want the window to be dependent on the
DOS window. I understand that pythonw gets around this, however I am
not having much luck. Thanks in advance for your help, Eric
 
D

Dennis Lee Bieber

Can I run pythonw with a script that takes command line arguments then
launches a GUI? I try pythonw myscript.pyw -option arg (etc.) and
nothing happens. Nothing, as in I am immediately returned to the DOS
prompt.
I don't think starting from a command line is any different
between "pythonw" and "python", they only show a difference when started
via "Windows" methods (double-clicking on an icon), where "python" will
CREATE stdio window vs "pythonw" suppressing that window.

Launching a GUI can be done from command line using the regular
"python" command, since the command line window is pre-existing.
the window is launched I do not want the window to be dependent on the
DOS window. I understand that pythonw gets around this, however I am

No.. pythonw only suppresses the creation of a console-type
window for applications that don't use stdio when when started from
Windows. Since you already have a console window the use of "pythonw" is
meaningless. If you mean you want the program to run "detached" from the
console then you probably need to use the Windows means of starting such
tasks:

start pythonw <script> <options>

"start" runs the rest of the command disconnected from the console; in
this situation "python" would realize it had no console and open a
window, "pythonw" would suppress the window expecting the program to
manage I/O via a GUI.


If you are getting nothing, the first thing I'd try is using
"python" rather than "pythonw" and see if some error trace shows up. As
"pythonw" is meant to suppress the creation of a stdio console, it
probably also doesn't take advantage of the one you have active, so all
stdio (including stderr) is suppressed.


--
 
E

Eric Ching

I post too soon. Looks like my problem is not so much with using
command line arguments as it is simply with pythonw. When I try using
pythonw with a script that works with the standard python
interpreter(after changing the extension to pyw), still I get the same
results(returns immediately to the command prompt) When I double
click on this script's icon nothing happens as well.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top