Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > A way to wait Python event

Reply
Thread Tools

A way to wait Python event

 
 
Chang LI
Guest
Posts: n/a
 
      11-30-2004
I tried to launch "python.exe test.py" in another program. After the
launch the console was showed and exited on Windows. I want the
console stay there. Is there a Python statement to wait an event loop
like Tcl's "after forever"?
 
Reply With Quote
 
 
 
 
Diez B. Roggisch
Guest
Posts: n/a
 
      11-30-2004
> I tried to launch "python.exe test.py" in another program. After the
> launch the console was showed and exited on Windows. I want the
> console stay there. Is there a Python statement to wait an event loop
> like Tcl's "after forever"?


I'm a happy linux user who is always amazed by such things when using
windows. So the first thing I do on a windows-box is to install cygwin, and
then execute commands from a proper shell.

Apart from that, I believe what you expirience has nothing to do with python
- windows just kills the command-window if your app exits. And thats well
after python is actually in command.

So maybe you can do somthing like this:

if __name__ == "__main__":
try:
... # do something
except:
print sys.exc_info()[1]
while True:
time.sleep(0.2)

That should stop the interpreter in case of an exception. Unindenting the
last while will wait in every case, so you can inspect the output
nonetheless.

Apart from that, there might be some hidden "keep this damn window open
after the executed progam terminated"-checkbox. Happy hunting.
--
Regards,

Diez B. Roggisch
 
Reply With Quote
 
 
 
 
Marcello Pietrobon
Guest
Posts: n/a
 
      11-30-2004
Chang LI wrote:

>I tried to launch "python.exe test.py" in another program. After the
>launch the console was showed and exited on Windows. I want the
>console stay there. Is there a Python statement to wait an event loop
>like Tcl's "after forever"?
>
>

If you need to keep a cmd window open maybe you can try this.
Unfortunately I don't have time to screen which lines are exactly the
ones you need.

I don't remember why it is like that.
For example I guess you can remove it the line realated to notepad

You'll figure out the best way to use it. But I suggest you to first
look at the preexisting values of those keys.
So you can come back to the preexisting situation if you don't like it (
you'll see


Take the following lines and put them in .reg file. Then run it.
After that when you right click on a file you'll have the option to open
it with Notepad or with a Command prompt that stays open.

Hope it helps.


Cheers,
Marcello


--------------------------------------------
REGEDIT4

[HKEY_CLASSES_ROOT\*]

[HKEY_CLASSES_ROOT\*\shell]

[HKEY_CLASSES_ROOT\*\shell\dos_box]
@="DOS Box"

[HKEY_CLASSES_ROOT\*\shell\dos_box\command]
@="cmd"

[HKEY_CLASSES_ROOT\*\shell\open]
@="Notepad"

[HKEY_CLASSES_ROOT\*\shell\open\command]
@="Notepad.exe %1"

[HKEY_CLASSES_ROOT\Folder\shell]

[HKEY_CLASSES_ROOT\Folder\shell\dos_box]
@="DOS Box"

[HKEY_CLASSES_ROOT\Folder\shell\dos_box\command]
@="cmd /k cd %1"

[HKEY_CLASSES_ROOT\batfile\shell]

[HKEY_CLASSES_ROOT\batfile\shell\runstayopen]
@="R&un - Stay open"

[HKEY_CLASSES_ROOT\batfile\shell\runstayopen\comman d]
@="cmd /k %1"

[HKEY_CLASSES_ROOT\comfile\shell]

[HKEY_CLASSES_ROOT\comfile\shell\runstayopen]
@="R&un - Stay open"

[HKEY_CLASSES_ROOT\comfile\shell\runstayopen\comman d]
@="cmd /k %1"

[HKEY_CLASSES_ROOT\exefile\shell]

[HKEY_CLASSES_ROOT\exefile\shell\runstayopen]
@="R&un - Stay open"

[HKEY_CLASSES_ROOT\exefile\shell\runstayopen\comman d]
@="cmd /k %1"

---------------------------



 
Reply With Quote
 
Josiah Carlson
Guest
Posts: n/a
 
      12-03-2004

http://www.velocityreviews.com/forums/(E-Mail Removed) (Chang LI) wrote:
>
> I tried to launch "python.exe test.py" in another program. After the
> launch the console was showed and exited on Windows. I want the
> console stay there. Is there a Python statement to wait an event loop
> like Tcl's "after forever"?


I'm a fan of...

_ = raw_input('press enter to continue...')


- Josiah

 
Reply With Quote
 
Schawm Schawm is offline
Junior Member
Join Date: Dec 2009
Posts: 5
 
      01-05-2010
Or you just do

import os
os.system("pause")

Itīs work well!!

Regards Schawm RS
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
wait for event hollex2108@yahoo.de Javascript 10 05-22-2008 07:20 AM
Proper way to wait for menu command and return? RajW C Programming 9 03-05-2006 02:38 PM
Portable way to wait for a keypress Alex007 C Programming 7 06-15-2004 05:13 PM
How to make "fork/wait" to WAIT longer? Huey C Programming 1 03-01-2004 02:01 PM
Re: best way to do a "please wait" message Craig Deelsnyder ASP .Net 1 08-04-2003 05:53 AM



Advertisments