title: Which events can be bound to a Tkinter Frame?
body: <p>I am making a small application with Tkinter. I would like to clean few things in a function called when my window is closed. I am trying to bind the <em>close event</em> of my window with that function. I don't know if it is possible and what is the corresponding sequence.</p>
  
  <p>The Python documentation says: <code>See the bind man page and page 201 of John Ousterhout’s book for details</code>.</p>
  
  <p>Unfortunately, I don't have these resources in my hands. Does anybody know the list of events that can be bound?</p>
  
  <p>An alternative solution would be to clean everything in the <code>__del__</code> of my Frame class. For an unknown reason it seems that it is never called. Does anybody knows what can be the cause? Some circular dependencies? </p>
  
  <p>As soon as, I add a control (uncomment in the code below), the <code>__del__</code> is not called anymore. Any solution for that problem?</p>
  
  <pre><code>from tkinter import *
  
  class MyDialog(Frame):
      def __init__(self):
          print("hello")
          self.root = Tk()
          self.root.title("Test")
  
          Frame.__init__(self, self.root)
          self.list = Listbox(self, selectmode=BROWSE)
          self.list.pack(fill=BOTH, expand=1)
          self.pack(fill=BOTH, expand=1)
  
  
      def __del__(self):
          print("bye-bye")
  
  dialog = MyDialog()
  dialog.root.mainloop()
  </code></pre>