title: How to make a button inside a class
body: <p>I have a chunk of code for a cookie clicker, but When i try to put it in a class it doesn't work, giving me this error</p>
  
  <pre><code>Exception in Tkinter callback
  Traceback (most recent call last):
    File "C:\Users\Travi\AppData\Local\Programs\Python\Python36-
  32\lib\tkinter\__init__.py", line 1699, in __call__
      return self.func(*args)
  TypeError: click() missing 1 required positional argument: 'self'
  </code></pre>
  
  <p>I don't understand why it doesn't work
  my code is as follows</p>
  
  <pre><code>from tkinter import*
  import os
  root = Tk()
  class Main():
      os.chdir('C:\\Users\\Travi\\Downloads')
      cookies = 0
      grandmas =0
      gmaprice = 10
  
      cookiesIcon = Label(root,text = "Cookies you have:"+str(cookies))
      cookiesIcon.grid(row = 1,column = 0)
      gma = Label(root,text = "Grandmas you have:"+str(grandmas))
      gma.grid(row = 0, column = 1)
      def click(self):
          global cookies,cookiesIcon
          cookies+=1
          cookiesIcon.config(text = "Cookies you have:"+str(cookies))
      def grandma(self):
          global cookies,grandmas,cookiesIcon,gma,gmaprice
          if cookies&gt;gmaprice:
              grandmas+=1
              cookies-=gmaprice
              gmaprice+=5
              cookies.config(text = "Cookies you have:"+str(cookies))
              gma.config(text = "Grandmas you have:"+str(grandmas))
      photo=PhotoImage(file = "Cookies.gif")
      b = Button(root,command =click)
      b.config(image=photo)
      b.grid()
      gmaupgrade=Button(root,command =grandma,text = "Grandmas for sale")
      gmaupgrade.grid(column = 1, row = 1)
      root.mainloop()
  </code></pre>