title: Trouble binding events in TKinter
body: <p>For background: most of my experience is ruby/rails. I'm trying to help a friend by building a simple GUI app that updates an Excel file and don't have much experience w/ Python or TKinter. The goal is to have a simple form, the user enters a number, and another form is shown with a drop down menu. I decided to store the given number in a global variable as I have had trouble trying to pass a variable between the two frames. I cannot manage to both set the global variable and switch to the second frame. Other questions/issues I've had are in ## marked comments. </p>
  
  <p>Alternatively, if anyone has any ideas on the best way to make a cross platform app that can access an MDB or excel file, I'm all ears. It kind of blows me away how difficult this has been. Thanks for any help.</p>
  
  <pre><code>import Tkinter as tk
  
  TITLE_FONT = ("Helvetica", 18, "bold")
  ID_NUMBER = None
  
  class StatusApp(tk.Tk):
      def __init__(self, *args, **kwargs):
          tk.Tk.__init__(self, *args, **kwargs)
  
          container = tk.Frame(self)
          container.pack(side="top", fill="both", expand=True)
          container.grid_rowconfigure(0, weight=1)
          container.grid_columnconfigure(0, weight=1)
  
          self.frames = {}
          for F in (EntryPage, StatusPage):
              frame = F(container, self)
              self.frames[F] = frame
              frame.grid(row=0, column=0, sticky="nsew")
  
          self.show_frame(EntryPage)
  
      def show_frame(self, c):
          '''Show a frame for the given class'''
          frame = self.frames[c]
          frame.tkraise()
  
  class EntryPage(tk.Frame):
      def __init__(self, parent, controller):
          tk.Frame.__init__(self, parent) 
          label = tk.Label(self, text="Enter ID:", font=TITLE_FONT)
          self.entry = tk.Entry(self)
          ## Using the lambda works to switch frames, but I need to be able to execute 
          ## multiple statements.
          # entry.bind('&lt;Return&gt;', lambda event: controller.show_frame(StatusPage))
  
          ## In examples I've seen, callback has been used without the empty parens, not sure
          ## why they're needed?
          self.entry.bind('&lt;Return&gt;', self.callback())
          label.pack(side="top", fill="x", pady=10)
          self.entry.pack()
          self.entry.focus_set()
  
      def callback(self):
          ## I noticed the following gets fired once the program starts
          print 'hello'
  
          ## For some reason it says that entry doesn't have the attribute 'set'. I don't
          ## understand this as I'm calling it like a method.
          self.entry.set('hello')
  
          ## Ultimately setting the global ID_NUMBER variable is one of the main goals of this
          ## function
          ID_NUMBER = self.entry.get()
  
          ## I haven't been able to switch frames from within this function, only w/ a lambda as
          ## seen on line 34.
          # show_frame(StatusPage())
  
  class StatusPage(tk.Frame):
      def __init__(self, parent, controller):
          tk.Frame.__init__(self, parent) 
          label = tk.Label(self, text="ID: ", font=TITLE_FONT)
          optionList = ('train', 'plane', 'boat')
          selected_opt = tk.StringVar()
          selected_opt.set(ID_NUMBER)
          menu = tk.OptionMenu(self, selected_opt, *optionList)
          button = tk.Button(self, text="Save", command=lambda: controller.show_frame(EntryPage))
          label.pack(side="top", fill="x", pady=10)
          menu.pack()
          button.pack()
  
  if __name__ == "__main__":
      app = StatusApp()
      app.mainloop()
  </code></pre>