title: Tkinter NameError
body: <p>I am trying to make a simple program that can select programs and start them, but when I select a porgram from the list it gives a name error</p>
  <pre><code>from tkinter import *
  
  class Window(Frame):
      def __init__(self, master=None):
          Frame.__init__(self,master)
          self.pack(fill=BOTH, expand=1)
  
          var=IntVar
  
          example=Checkbutton(self, text=&quot;example&quot;, variable=var, onvalue=1, offvalue=0, command=self.example)
          example.place(x=0,y=0)
          
      def example(self):
          if (example.get() == 1):
              print(&quot;1&quot;)
          elif (example.get() == 0):
              print(&quot;0&quot;)
  
  root=Tk()
  app=Window(root)
  root.geometry(&quot;220x120&quot;)
  root.resizable(width=False, height=False)
  root.mainloop()
  </code></pre>
  <p>When I run this, it works fine but upon clicking the checkbox it gives the error</p>
  <blockquote>
  <p>NameError: name 'example' is not defined</p>
  </blockquote>
  <p>i've tried searching with different keywords but haven't found a solution. The only progress i made was to remove the <code>(self)</code> from behind <code>def example</code>, which then gave the following error</p>
  <blockquote>
  <p>TypeError: example() takes 0 positional arguments but 1 was given</p>
  </blockquote>
  <p>any help would be very appreciated</p>