irritating problem

John Roth newsgroups at jhrothjr.com
Mon Sep 15 20:08:01 EDT 2003


"Park997" <park997 at aol.comnotospam> wrote in message
news:20030915150042.22749.00001062 at mb-m23.aol.com...
> Hi,
>
> I have a script that runs correctly in IDLE, runs correctly when invoked
in the
> Command Prompt (Win XP), runs correctly from Komodo, but flashes a black
box
> too fast to see when the icon is double clicked and produces no output.
There
> are no error meassages from any of the methods that produce output. All of
the
> other modules in the same directory (these are imported to the problem
module)
> work correctly in any start mode.
>
> python 2.3.
>
> Obviously this isn't a disaster, but it "bugs" me. Is there a fix or
method of
> obtaining diagnostic information on this?

When you say "all of the other modules ... work correctly in any start
mode,"
do you mean that when you double click on the icon they come up in a dos
box and the box stays around after the module exits? Or does your comment
about importing them mean that you don't attempt to run them independently?

There are *two* command prompts in Windows XP. One is the Command
Prompt you seem to be using (the one with the "c:" icon), the other is the
DOS box.
It's cleverly hidden, but it still exists.

The default action for both of them is to run the command and then exit
immediately; that's why you get the black box that flashes and then
vanishes.
If your script provides a keyboard interface, the console window will stay
around as long as you keep reading keyboard input; it will still go away
immediately when you exit from the console loop and exit the Python script.

There's no obvious way I know of to double click on a Python icon and
have the XP console window stay around after the script exits. This is
because
Python itself invokes the command line processor, and there's no
opportunity to pass it the -k (I think that's the one) parameter.

What I do in the rare cases where I want to directly invoke a Python
script and have the console window stay around is to create one
(or sometimes two) .cmd files. The first .cmd file
invokes a second copy of the XP command line with the -k parameter
(which makes it stay around) and then Python itself.

[cmdfile1.cmd example]

cmd -k python myscript.py parameters...

[end of command script]

This doesn't allow you to set environment variables. If you want to
do that, you need two .cmd files.

[cmdfile1.cmd example]
cmd -k cmdfile2.cmd
[end of cmdfile1.cmd]

[cmdfile2.cmd example]
set envvar=somethingOrOther
python myscript.py theWorldsGreatestParameter
[end of cmdfile2.cmd]

HTH

John Roth


>
> Thanks,
>
> Wendell Cropper






More information about the Python-list mailing list