title: Errors with Multiple Events Calling a Single Function in Python 3.4 w/ tkinter
body: <p>I am trying to make use of arguments in bound events. I am using python 3.4 with tkinter 8+(not sure atm). My questions are:</p>
  
  <p>1) When I declare n1 <em>after</em> the button binding, the code says n1 is undefined (duh)</p>
  
  <p>2) When I declare n1 <em>before</em> the button binding, the function is called when the button is drawn and <strong>never</strong> when it is clicked (this is the version shown below), which is the desired functionality (to allow the user to embed logic symbols in otherwise free input using ASCII font).</p>
  
  <p>3) The first button demonstrates that in a function without arguments, it knows who the out of scope widget "n1" is; however, if I were to add a single argument (to pass the text desired to be displayed), then the code doesn't compile, with the error "n1" undefined.</p>
  
  <p>4) I realize I could make a unique function for each binding and skip the arguments, but I am obsessed with the idea of a single function.</p>
  
  <p>5) I've seen examples, and have compiled and ran them, that use the "event" argument that is not explicitly referred to in the binding/definition. While for some reason this, and the variant "*args", does not cause the "n1" out of scope issue above, when I attempt to write my own code in this manner either "*args" is empty, or "event" is declared undefined, etc. (was hoping to try event.widget to detect which button called the function). I simply haven't wrapped my head around these examples in a way to apply to my own code successfully.</p>
  
  <p>Essentially I am hoping to have multiple events call the same function that performs the same task for each event, with minor distinctions based on which widget made the call, as suggested in the code below. Maybe I'm spinning my wheels when I have a known solution (multiple vs. single functions), but I would greatly like to expand my skill-set, particularly in the area of accessing event attributes. Thank-you for your assistance!!</p>
  
  <pre><code>from tkinter import *
  from tkinter import ttk
  
  root = Tk()
  
  def noArg():
      n1.insert('insert','I know who n1 is')
  
  def addSymbol(t,s):
      t.insert('insert',s)
  
  p = ttk.Panedwindow(root, orient=VERTICAL)
  #-------------------------------------------------------
  #second pane will contain the work area via notebook containing text widgets
  #-------------------------------------------------------
  n = ttk.Notebook(p)
  n1 = Text(n,width=50,height=10);
  n.add(n1, text='Argument')
  n1['state']='normal' 
  
  #-------------------------------------------------------
  #first pane will contain buttons to modify the workspace
  #-------------------------------------------------------
  bWidth = '36p'
  f = ttk.Frame(p)
  f['width']='504p'
  f['height']='18p'
  #button to add noArg binding
  b = ttk.Button(f, text='hah!', command=noArg)
  b['width']=bWidth
  b.grid(row=0,column=0)
  #button to add conditional symbol
  b = ttk.Button(f, text=u'\u2e27', command=addSymbol(n1,u'\u2e27'))
  b['width']=bWidth
  b.grid(row=0,column=1)
  #button to add biconditional symbol
  b = ttk.Button(f, text=u'\u2261', command=addSymbol(n1,u'\u2261'))
  b['width']=bWidth
  b.grid(row=0,column=2)
  p.add(f)
  p.add(n)
  
  p.grid()
  
  root.mainloop()
  </code></pre>