python - unbound method x() must be called with y instance as first argument (got int instance instead) -


my python-program has quite lot of code hope you're fine give part of code problem about. i've created thread tkinter , trying access function within thread. looks like:

class gui (threading.thread):      def __init__(self, num):          threading.thread.__init__(self)       def run(self):          window = tk()          window.title('gui')          window = canvas(window, width=400, height=200)          window.pack()        def output(lampe, status):          if status == 0:               if lampe == 21:                  window.create_oval(140, 30, 160, 10, fill="#ffa6a6")              if lampe == 20:                  window.create_oval(170, 30, 190, 10, fill="#fafaaa")   gui.output(21,0) 

and message get:

typeerror: unbound method output() must called gui instance first argument (got int instance instead)

to honest, not know instance have refer first argument.

you're trying access static method, you'll need annotate @staticmethod

    @staticmethod     def output(lampe, status):          if status == 0:               if lampe == 21:                  window.create_oval(140, 30, 160, 10, fill="#ffa6a6")              if lampe == 20:                  window.create_oval(170, 30, 190, 10, fill="#fafaaa") 

Comments