TypeError: __init__() takes 1 positional argument but 2 were given

Rich Shepard rshepard at appl-ecosys.com
Thu Apr 29 17:25:42 BST 2021


On Thu, 29 Apr 2021, Stephen Waterbury wrote:

> Yes, that error message is confusing if you haven't seen it before -- in
> python, any bound method implicitly/automagically gets the "self"
> argument, so calling it without arguments already gives it one argument,
> "self".  In your code, you explicitly added "self", so that is considered
> a second argument.  So if the __init__ method for SitesWindow has a
> signature like:  def __init__(self): ... then you can just create a
> SitesWindow using"SitesWindow()".

Steve,

I thought that might be the case because sites.py has the class:
class SitesWindow(qtw.QWidget):
     def __init__(self):
         super().__init__()
         sites = qtw.QWidget(windowTitle='Locations')

So I edited mwe.py to call
 	tabs.addTab(self.sw, 'Sites')

and I get a blank window; I'm still missiong a step or three.

Thanks very much,

Rich


More information about the PyQt mailing list