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

Ludovic Bellière belliere.ludovic at proximus.be
Thu Apr 29 19:56:30 BST 2021


Rich,

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.

Ludovic

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()".
> 
> 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20210429/ec9f731b/attachment.sig>


More information about the PyQt mailing list