title: Python Tkinter menubar
body: <p>Below is some sample code, everything works as far as the menu, and the gui for the function, but the function doesn't work when you pass values it, when what I want it to do is calculate the problem, as it is designed to.</p>
  
  <p>i want the function to be a separate program, to the main window, as it is.
  The reason is I want to add more of these mathematical functions to a menu. </p>
  
  <p>How can I get this function to work? I am new, go easy please....
  Thank you in advance...</p>
  
  <pre><code>from Tkinter import *
  import ttk
  
  
  def DVT():
      def dvt(*args):
          """This Function will determine distance in feet from a constant velocity and time"""
          try:
              val1 = float(vel.get())
              val2 = float(tme.get())
              dist.set(val1 * val2)
          except ValueError:
              pass
  
      root = Tk()
      root.title('Distance from Velocity and Time')
  
      mainframe = ttk.Frame(root, padding="3 3 12 12")
      mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
      mainframe.columnconfigure(0, weight = 1)
      mainframe.rowconfigure(0, weight=1)
  
      vel = StringVar()
      tme = StringVar()
      dist = StringVar()
  
      vel_entry = ttk.Entry(mainframe, width=7, textvariable=vel)
      vel_entry.grid(column=2, row=1, sticky=(E, W))
      tme_entry = ttk.Entry(mainframe, width=7, textvariable=tme)
      tme_entry.grid(column=2, row=2, sticky=(E, W))
  
      ttk.Label(mainframe, textvariable=dist).grid(column=2, row=3, sticky=(W, E))
      ttk.Button(mainframe, text="Calculate", command=dvt).grid(column=3, row=2, sticky=W)
      ttk.Label(mainframe, text="Velocity").grid(column=1, row=1, sticky=(W, E))
      ttk.Label(mainframe, text="Time").grid(column=1, row=2, sticky=W)
      ttk.Label(mainframe, text="The Distance is:").grid(column=1, row=3, sticky=E) 
  
      for child in mainframe.winfo_children(): child.grid_configure(padx=5, pady=5)
  
      vel_entry.focus()
      tme_entry.focus()
      root.bind('&lt;Return&gt;', dvt) 
      root.mainloop()
  
  
  root = Tk()
  menubar = Menu(root)
  
  
  vel = StringVar()
  tme = StringVar()
  dist = StringVar()
  
  
  filemenu = Menu(menubar, tearoff=0)
  filemenu.add_command(label="Distance from Velocity and Time", command=DVT)
  
  filemenu.add_separator()
  
  filemenu.add_command(label="Exit", command=root.quit)
  menubar.add_cascade(label="File", menu=filemenu)
  editmenu = Menu(menubar, tearoff=0)
  
  
  editmenu.add_separator()
  
  root.config(menu=menubar)
  root.mainloop()
  </code></pre>