title: how does a check button work in a Tkinter menu?
body: <p><strong>goal</strong></p>
  
  <p>To understand how the check button works in a Tkinter menu. Especially how the value of the variable associated is changed and when the function mentioned in the command is called.</p>
  
  <p><strong>code</strong></p>
  
  <p>I have the following checkbutton that I have added to a Tkinter menu:</p>
  
  <pre><code>window = Tk()
  
  shown = BooleanVar()
  shown.set(True)        
  
  menubar = Menu(window)
  
  
  optionsmenu = Menu(menubar,tearoff=0) 
  
  optionsmenu.add_checkbutton(label='Show timing after the run is completed',command=PopUp,variable=shown,onvalue = True,offvalue = False)
  </code></pre>
  
  <p>For simplicity the on value of the check button is <code>true</code> and the off value is <code>false</code>.</p>
  
  <p><strong>what I want to know:</strong></p>
  
  <ol>
  <li>Is the value of the variable changed when the check button is pressed or is the function called and the value of the variable needs to be changed explicitly?</li>
  <li>Is the command executed before the variable is toggled or after it has been toggled??</li>
  </ol>
  
  <p><strong>specs</strong></p>
  
  <p>Windows XP SP3</p>
  
  <p>Python 2.7</p>
  
  <p><strong>Please</strong> help me with this doubt.</p>