TKinter -- '<Destroy>' event executing more than once?
Christopher Subich
spam.csubich+block at block.subich.spam.com
Sat Jun 11 19:43:24 EDT 2005
I'm building an application involving both twisted and Tkinter. Since
twisted co-opts <widget>.mainloop() in its reactor.run(), and since it
behaves very badly if the application quits without reactor.stop()
running, I attach the following function to '<Destroy>' in the main
window (root = Tk()):
def stop_reactor_bind(x):
reactor.stop()
Then:
root.bind('<Destroy>',stop_reactor_bind)
The problem, however, comes that when I add a Text widget inside the
root window, upon destroying the window (closing it) the callback seems
to execute twice. In interactive testing, it's executed once per widget
inside the root window. Since twisted doesn't take multiple
reactor.stop()s gracefully, how (short of wrapping this inside a
class/scope that keeps state) can I ensure that the callback executes
only once? Am I attaching to the wrong signal?
More information about the Python-list
mailing list