irritating problem

P

Park997

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?

Thanks,

Wendell Cropper
 
G

Geoff Gerrietts

Quoting Park997 ([email protected]):
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.

It would be useful to know specifically what output you are expecting
versus what output you are getting.

If it's flashing the box and disappearing, it's conceivable that you
could change the properties such that the cmd window doesn't disappear
after the program completes, right?

Thanks,
--G.
 
P

Peter Hansen

Park997 said:
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.

Can you select Properties for that icon and change it so it doesn't close
the window automatically when the program terminates?

Or is this just using the default settings after you've installed Python,
in which case it's being run using the assocation for the .py file extension?
In that case, you should go to Explorer, under View->Folder Options. Then
click the File Types tab, scroll down until you find the entry for the Python
files (make sure you use .py or .pyw as appropriate), then click on Edit,
then on Run in the Actions area, then on Edit. You should then see, in about
the 19th dialog that has popped up (isn't Windows wonderful?! Truly those at
Microsoft are masters of good user interface design!), the actual command
that is being executed when you click on the icon. I suspect it uses the
directory that the .py file is in as the current directory, and it should
show an absolute path to where it thinks Python should be, then something
like "%1" %* which roughly means execute the file using the exact command
plus the filename in quotation marks. I suspect the %* does nothing in most
cases.

If you can then go to the DOS prompt in the same directory, and type the
same command, and everything works.... well then you've got a problem on
your hands, don't you? ;-) (But let us know more, then, as there are
doubtless other steps to take.)

-Peter
 
J

John Roth

Park997 said:
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
 
P

Park997

Can you select Properties for that icon and change it so it doesn't close
the window automatically when the program terminates?

Or is this just using the default settings after you've installed Python,
in which case it's being run using the assocation for the .py file extension?
In that case, you should go to Explorer, under View->Folder Options. Then
click the File Types tab, scroll down until you find the entry for the Python
files (make sure you use .py or .pyw as appropriate), then click on Edit,
then on Run in the Actions area, then on Edit. You should then see, in about

the 19th dialog that has popped up (isn't Windows wonderful?! Truly those at
Microsoft are masters of good user interface design!), the actual command
that is being executed when you click on the icon. I suspect it uses the
directory that the .py file is in as the current directory, and it should
show an absolute path to where it thinks Python should be, then something
like "%1" %* which roughly means execute the file using the exact command
plus the filename in quotation marks. I suspect the %* does nothing in most
cases.

If you can then go to the DOS prompt in the same directory, and type the
same command, and everything works.... well then you've got a problem on
your hands, don't you? ;-) (But let us know more, then, as there are
doubtless other steps to take.)

-Peter

Thanks to everybody for the help. It turns out that there are two separate
python programs associated with the .py extention in windows. I have installed
Python 2.3 over 2.22 and 2.0 without removing any of the previous versions.
This is a numerical program using psyco (only available with the 2.3
installation. When I comment out the psyco import, it runs the double clicked
icon OK.

Thanks again to everybody for the help.

Wendell Cropper
 

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

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top