Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   irritating problem (http://www.velocityreviews.com/forums/t322508-irritating-problem.html)

Park997 09-15-2003 07:00 PM

irritating problem
 
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

Geoff Gerrietts 09-15-2003 08:28 PM

Re: irritating problem
 
Quoting Park997 (park997@aol.comnotospam):
> 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.

--
Geoff Gerrietts "I think doorways are sexist."
<geoff at gerrietts net> --Jayson Lockwood


Peter Hansen 09-15-2003 08:32 PM

Re: irritating problem
 
Park997 wrote:
>
> 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

John Roth 09-16-2003 12:08 AM

Re: irritating problem
 

"Park997" <park997@aol.comnotospam> wrote in message
news:20030915150042.22749.00001062@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




Park997 09-16-2003 12:23 PM

Re: irritating problem
 
>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

Christos TZOTZIOY Georgiou 09-16-2003 01:03 PM

Re: irritating problem
 
On Mon, 15 Sep 2003 16:32:03 -0400, rumours say that Peter Hansen
<peter@engcorp.com> might have written:

[snip]
>(isn't Windows wonderful?! Truly those at
>Microsoft are masters of good user interface design!)

[snip]

Playing the devil's advocate, an old joke about intuitive interfaces
comes to mind (a recent reference:
http://groups.google.com.gr/groups?s...40deadspam.com
:)
--
TZOTZIOY, I speak England very best,
Microsoft Security Alert: the Matrix began as open source.

Peter Hansen 09-16-2003 02:59 PM

Re: irritating problem
 
Christos TZOTZIOY Georgiou wrote:
>
> On Mon, 15 Sep 2003 16:32:03 -0400, rumours say that Peter Hansen
> <peter@engcorp.com> might have written:
>
> [snip]
> >(isn't Windows wonderful?! Truly those at
> >Microsoft are masters of good user interface design!)

> [snip]
>
> Playing the devil's advocate, an old joke about intuitive interfaces
> comes to mind (a recent reference:
> http://groups.google.com.gr/groups?s...40deadspam.com
> :)


Cute. That must explain the prevalence of so much "nipple-ware" on the web
these days... ;-)

-Peter


All times are GMT. The time now is 04:48 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.