title: tkinter radio buttons does not work inside function
body: <p>I am trying to write a GUI (in fact a <a href="http://www.pymol.org/" rel="nofollow">PyMOL</a> plugin) with radio buttons. I need the radio buttons to be inside a function.  I have two problems (if the radio buttons are outside a function I don´t have any problem): </p>
  
  <p>1) the last two radio button looks gray and checked. (I think the correct behavior should be only one checked and none gray) setting a different default value (using ref_value.set()) does not change anything</p>
  
  <p>2) I always get the default value ("1" in this example) when hit the submit button.</p>
  
  <pre><code>from Tkinter import *
  
  def __init__(self):
      """this adds the Plugin to the PyMOL menu"""
      self.menuBar.addmenuitem('Plugin', 'command',
                          'Plugin name',
                          label = 'plugin',
                          command = lambda : draw_gui())
  
  def draw_gui():
      global v
      master = Tk()
      master.title(' title ')
      Button(master, text='Submit', command=submit).pack(side=BOTTOM)
      v = StringVar()
      v.set(1)
      Radiobutton(master, text='option 1', variable=v, value=1).pack(side=LEFT)
      Radiobutton(master, text='option 2', variable=v, value=2).pack(side=LEFT)
      Radiobutton(master, text='option 3', variable=v, value=3).pack(side=LEFT)
      master.mainloop()
  
  
  def submit():
      print v.get()
  </code></pre>
  
  <p>Thanks in advance</p>