My escape event isn't working
Question: I'm trying to make a program that when I press escape on the window appears a
label "You pressed Escape".

    
    
    from tkinter import *
    
    class the_Esc_test(Frame):
       def __init__(self):
          Frame.__init__(self)
          self.start_number=0
          self.pack(expand=YES, fill=BOTH)
          self.master.title("Esc program")
          self.master.geometry ("600x600")
    
          self.bind("<Escape>", self.EscPressed)
    
      def EscPressed(self):
         self.start_number+=1
         if self.start_number==1:
             self.lbl1=Label(self, text="You pressed Escape")
             self.lbl1.grid(row=6, column=6, sticky=W)
    
         elif self.start_number==2:
             self.lbl1.grid_forget()
             self.start_number=0
    
    start=the_Esc_test()
    

It doesn't work, but Python will not show any error.

Can someone show me why?


Answer: I was able to get it to work like so

    
    
    from Tkinter import *
    
    class the_Esc_test(Frame):
        def __init__(self):
            Frame.__init__(self)
            self.start_number=0
            self.pack(expand=YES, fill=BOTH)
            self.master.title("Esc program")
            self.master.geometry ("600x600")
    
            self.master.bind("<Escape>", self.EscPressed)
    
        def EscPressed(self, event):
            print "called", event.keysym
    
    start=the_Esc_test()
    start.mainloop()
    

