473,405 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

A way to wait Python event

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"?
Jul 18 '05 #1
4 9403
> 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
Jul 18 '05 #2
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"

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

Jul 18 '05 #3

ch********@hotmail.com (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

Jul 18 '05 #4

ch********@hotmail.com (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

Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: | last post by:
At long last I am pleased to announce that there will once again be a UK Python event this year. This is being organised as a track within the ACCU (Association of C and C++ Users) conference. It...
1
by: Somesh Bartakkay | last post by:
Am basically from India - Pune. here is very less (say NO) Python AwareNess .. so i wanna increase it.. am trying in my own way but for making it in VERY proffesional manner and on very HIGH...
4
by: Michael | last post by:
>>Right. Then we can have "does the brace go on the same line or the >>next line" wars. >> >> > > int main (void) > { > if (true) > { > }
2
by: Markus von Ehr | last post by:
Hi everybody, I'd like to create an event which I have to post/set within an extension (new frame signal from a camera). In python I would like to react on this event. How could I create and...
1
by: R A | last post by:
Hi How do I create Event handle same as using the win32 CreateEvent? I need the ..net app (c#) to wait for event (such as win 32 waitforsingleobject api). Thanks, Ron
4
by: Peter Otten | last post by:
QOTW: "It's hard to make a mistake by having too many short and simple functions. And much too easy to make them when you have too few ;-)" - Thomas Bartkus "Argh, the following is valid Python...
2
by: dudds | last post by:
Hi I really haven't used wxPython before and I was just wondering if there was some sort of timer event that can be used. For example if I have a database that I want to query at regular intervals...
10
by: hollex2108 | last post by:
Hi, I search for a method how my function detect an event while js is carry out a loop. I think it's not really important for a problem solving, but goodness knows: I want to automate a...
15
by: Phillip B Oldham | last post by:
Are there any python event driven frameworks other than twisted?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.