Search code examples
pythonwxpython

Why does the use of *args and **kwargs throw an error in wxpython?


Running this code results an in error

import wx

class MyFrame(wx.Frame):
    def __init__(self, *args, **kwargs):
        wx.Frame.__init__(self, args, kwargs)
        self.Show()

app = wx.App()
frame = MyFrame(None)
app.MainLoop()


Traceback (most recent call last):
  File "testing.py", line 10, in <module>
    frame = MyFrame(None)
  File "testing.py", line 6, in __init__
    wx.Frame.__init__(self, args, kwargs)
  File "C:\Python27\lib\site-packages\wx-2.9.4-msw\wx\_windows.py", line 580, in __init__
    _windows_.Frame_swiginit(self,_windows_.new_Frame(*args, **kwargs))
TypeError: in method 'new_Frame', expected argument 1 of type 'wxWindow *'

Is it possible to use *args and **kwargs for positional and named arguments in wxpython?


Solution

  • wx.Frame.__init__(self, *args, **kwargs)
    

    it works fine ... btu you need to pass them correctly