title: How to pass arguments to a Button command in Tkinter?
body: <p>Suppose I have the following <code>Button</code> made with Tkinter in Python:</p>
  <pre><code>import Tkinter as Tk
  win = Tk.Toplevel()
  frame = Tk.Frame(master=win).grid(row=1, column=1)
  button = Tk.Button(master=frame, text='press', command=action)
  </code></pre>
  <p>The method <code>action</code> is called when I press the button, but what if I wanted to pass some arguments to the method <code>action</code>?</p>
  <p>I have tried with the following code:</p>
  <pre><code>button = Tk.Button(master=frame, text='press', command=action(someNumber))
  </code></pre>
  <p>This just invokes the method immediately, and pressing the button does nothing.</p>
  <hr />
  <p><sub>If you try to create multiple Buttons in a loop, passing each one different arguments based on the loop counter, you may run into problems due to what is called <em>late binding</em>. Please see <a href="https://stackoverflow.com/questions/10865116/">tkinter creating buttons in for loop passing command arguments</a> for details.</sub></p>