title: how to close a window with a bind event in tkinter
body: <p>My problem is in to close de window created when the cursor moves on the question button, and a try to close the new window when the cursor leaves de question button. I tryed exchange destroy method for quit method it does not work too. The code is below</p>
  
  <pre><code>#!/usr/bin/env python
  
  import tkinter as tk
  
  class Application(tk.Frame):
      def __init__(self, master=None):
          tk.Frame.__init__(self, master)
          self.grid()
          self.createWidgets()
  
      def createWidgets(self):
  
          self.texto = tk.Label(self, text='defina o tamanho do lado')
          self.texto.grid(row=0, column=0)
  
          self.texto2 = tk.Label(self, text='defina o valor do lado')
          self.texto2.grid(row=1, column=0)
  
          self.imagem_1 = tk.PhotoImage(file='F:/.../question.png')
  
          self.button_ajuda = tk.Button(self, image= self.imagem_1, height=15, width=15)
          self.button_ajuda.grid(row= 1, column=2)
          self.button_ajuda.bind('&lt;Enter&gt;', self.info)# evento para abrir janela info ao passar o cursor sobre o botão
          self.button_ajuda.bind('&lt;Leave&gt;', self.info_close)# evento para fechar janela info
  
          self.entrada = tk.Entry(self, width=5) #define o widget de entrada 'width' é o tamanho
          self.entrada.grid(row=0, column=1)# define a posição do widget de entrada
  
          self.entrada2 = tk.Entry(self, width=5)
          self.entrada2.grid(row=1, column=1)
  
      def info(self, event):
          val = 0
          win = tk.Toplevel(self)
          texto_info='''b is basis of rectangle
                      (a) will be (l) if (b) is lowest side
                      or (h) if (b) is the highest side of
                      the rectangle'''
          tk.Label(win, text= texto_info).pack()
          x= win.winfo_pointerx()+100
          y= win.winfo_pointery()
          win.geometry('+%d+%d'%(x,y))
          win.overrideredirect(1)
          if val == 1:
              win.destroy()
       def info_close(self, event):
          global val
          val =1
  
  app = Application()
  app.master.title('Aureum')
  app.mainloop()
  </code></pre>