-2

I have the following code:

import Tkinter
from labrad.server import LabradServer

class MyController(LabradServer,Tkinter.Tk):
    def __init__(self, var, parent=None):
        LabradServer.__init__(self)
        Tkinter.Tk.__init__(self,parent)
        self.parent = parent

if __name__ == "__main__":
    app = MyController(9)
    app.title('Controller')
    app.mainloop()

When I run this, however, I get TypeError: __init__() takes exactly 1 argument (3 given). I know this is from the second __init__() call, since I can freely print something after the LabradServer.__init__(self) and it will print before the error is triggered. Any idea what is causing this, or how to fix it?

Nathan Tuggy
  • 2,237
  • 27
  • 30
  • 38
roboguy222
  • 157
  • 13
  • 1
    in `MyController` your `__init__` takes 3 arguments yet you only pass it two (the `MyController` instance and the integer `9`). Maybe this is the problem ? – wsdookadr Apr 30 '15 at 02:26
  • you might also want to read about [`super()`](http://stackoverflow.com/a/3277407/827519) and how it's used to call base class constructors. – wsdookadr Apr 30 '15 at 02:35

1 Answers1

2

Tkinter.Tk.__init__(self,parent) takes 1 argument, but you gave it 3. Try:

Tkinter.Tk.__init__()

instead.

Patrick Collins
  • 10,306
  • 5
  • 30
  • 69