[Tutor] How can I catch a Windows event?
goldperger at st.nograd.net
goldperger at st.nograd.net
Sun Aug 29 11:03:54 CEST 2004
Hi,
I am new in computing and python. My problem is during
switching off/ restaring Win 98 the phyton script written by me
doesnt stop. (in Win XP. no problem)
I gues it is because of a thread. By checking from the internet
I found the WM_QUERYENDSESSION should be caught for regular
stopping, but I do not understand how.
I am also not sure, which I should use win 32all or wxPython.
The following script stops the win98 shutdown process if I start the script from consol.
python 2.3.3 Win98SE
#--------------------------------------------------------------------------
from threading import Thread
from time import sleep
stop_now=0 #It must changed into 1 when event WM_QUERYENDSESSION happens
class Test_thread_app(Thread):
def run(self):
global stop_now
n=0
while n<10 and (not stop_now):
sleep(5)
n=n+1
print str(n)
if __name__=="__main__":
myApp=Test_thread_app()
myApp.start()
myApp.join()
#----------------------------------------------------------------------------
Is there any solution for catching this kind of event?
Is there other solution advised?
Andras Goldperger
More information about the Tutor
mailing list