While I thought I understood class instatiation with wxPython I've
discovered that I still lack complete understanding. I've read the Python3
doc, Chapter 9 (Classes), Sections 9.3.3--9.3.5 and cannot find my error. I
want to learn to properly initialize and instantiate wxPython4 classes so
pointers to other references will be appreciated.
The current issue is adding panels to a notebook. Both the wx.Frame and
wx.Notebook are in the same module and the notebook panels are imported at
the top of this module; e.g.,
from sitePage import SiteGrid
and the notebook class is attached to the frame at the end of the wx.Frame
class:
# Attach notebook
self.theNB = MainNB(self, id=wx.ID_ANY)
The notebook class:
class MainNB(wx.Notebook):
def __init__(self, parent, id):
wx.Notebook.__init__(self, parent, id, style=wx.NB_TOP)
self.panel1 = SiteGrid(self,wx.ID_ANY)
# plus the other panels.
self.AddPage(self.panel1, "Sites")
# plus the other panels.
When I run the main module there's a type error:
$ ./openEDMS.py Traceback (most recent call last):
File "./openEDMS.py", line 320, in <module>
top = MainFrame(None, 'openEDMS')
File "./openEDMS.py", line 161, in __init__
self.theNB = MainNB(self, id=wx.ID_ANY)
File "./openEDMS.py", line 283, in __init__
self.panel1 = SiteGrid(self,wx.ID_ANY)
TypeError: __init__() takes 1 positional argument but 3 were given
My readings haven't shown me where this inconsistency arises and I do need
to learn how to avoid these TypeErrors in the future.
TIA,
Rich