Bob Greschke wrote: > Hi! > > I want to grab the contents of a Text widget when the frame it's on gets > destroyed. I tried TextWidget.bind("<Destroy>"... , but the widget is gone > before the call gets made, and I'd really hate to do something with the > function that gets called with TextWidgetsFrame.bind("<Destroy>", ..., since > that one function handles all of the frames in the program...or would that > even work? > > How can I do this? > > Thanks! > > Bob > >
If TextWidgetsFrame inherets from frame, you can override the destroy() method which gets called when the parent gets destroyed. Or alternatively, you can override the __del__ function, which gets called when the reference count goes to 0: py> from Tkinter import * py> tk = Tk() py> class F(Frame): ... def destroy(self): ... print 'bob' ... Frame.destroy(self) ... py> f = F(tk) py> f.pack() py> tk.destroy() bob James -- http://mail.python.org/mailman/listinfo/python-list