TypeError: __init__() takes 1 positional argument but 2 were given
belliere.ludovic at proximus.be
Thu Apr 29 19:56:30 BST 2021
Don't forget to add your content widgets to a layout, and then that
layout to your window. I'm pretty sure content widgets (like a text area
or whatever) will not be displayed unless they're within a layout.
On jeu, 29 avr 2021, Rich Shepard wrote:
> 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()".
> I thought that might be the case because sites.py has the class:
> class SitesWindow(qtw.QWidget):
> def __init__(self):
> 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,
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 833 bytes
Desc: not available
More information about the PyQt