How to catch windows shutdown/reboot message
I'm writing a python script which runs as a windowsxp service. The problem is how to catch the windows shutdown/reboot message and do some cleaning job when system is going down? The atexit module and signal module on windows dont seems to work. I guess the python win32api may be of help, but I am not familiar with it... Thank you -- http://mail.python.org/mailman/listinfo/python-list
Re: beginner python GUI question
于 2010-8-2 6:15, Chris Hare 写道:
I hope I can explain this correctly.
I have a GUI, which is already being processed by a mainloop. I want to be
able to open a second window so the user can interact with specific information
in the second window. I pulled together this code example
from Tkinter import *
class Net:
def __init__(self,tkWin):
self.window = tkWin
def show(self,t):
self.l = Label(self.window,text=t)
self.l.grid()
button = Button(self.window, text="Again")
button.bind("", self.Again)
button.grid()
def Again(self,event):
win3 = Tk()
x = Net(win3)
x.show("window 3")
root = Tk()
root.title = "test"
f = Frame(root,bg="Yellow")
l = Label(f,text="window 1")
f.grid()
l.grid()
win2 = Tk()
x = Net(win2)
x.show("window 2")
if __name__ == "__main__":
root.mainloop()
Is this the right way to do things, or would you suggest something different?
Thanks,
Chris
Using Tkinter.Toplevel may be better. :)
--
http://mail.python.org/mailman/listinfo/python-list
Re: How to catch windows shutdown/reboot message
于 2010-8-2 16:00, Tim Golden 写道: On 02/08/2010 02:17, rechardchen wrote: I'm writing a python script which runs as a windowsxp service. The problem is how to catch the windows shutdown/reboot message and do some cleaning job when system is going down? The atexit module and signal module on windows dont seems to work. I guess the python win32api may be of help, but I am not familiar with it... Thank you Have a look at the SENS stuff: http://timgolden.me.uk/python/win32_how_do_i/track-session-events.html TJG Thanks, the extended handler functionality works. :) -- http://mail.python.org/mailman/listinfo/python-list
