Maximum recursion depth exceeded in wxPython

import wx

class Bucky(wx.Frame):
    def __init__(self, parent, id):
        wx.Frame.__init__(self, parent, id, 'Frame aka window', size=Bucky(300, 200))

if __name__ == '__main__':
    app = wx.PySimpleApp()
    frame = Bucky(parent=None, id=-1)
    frame.show()
    app.MainLoop()



when this code is run 'maximum recursion depth exceeded' error pops up and the code terminates. Any solution?

You have a couple of problems with this code. First off, you are hitting the recursion limit because you can reinstantiating the Bucky class recursively in your init method. See the size parameter?

size=Bucky(300, 200))
Yeah, that's a bad thing. It should be **size=(300, 200))**. Then you won't hit the recursion limit. Also the second to last line should be **frame.Show()**. Note the capital "S"

Hope that helps,
Mike

···

On Thursday, February 19, 2015 at 12:13:24 PM UTC-6, Anonym wrote:

import wx



class Bucky(wx.Frame):
    def __init__(self, parent, id):
        wx.Frame.__init__(self, parent, id, 'Frame aka window', size=Bucky(300, 200))


if __name__ == '__main__':
    app = wx.PySimpleApp()
    frame = Bucky(parent=None, id=-1)
    frame.show()
    app.MainLoop()





when this code is run 'maximum recursion depth exceeded' error pops up and the code terminates. Any solution?

What is this supposed to mean in your Frame init call?:

size=Bucky(300, 200)

Because what it is doing, is trying to make ANOTHER Bucky object,
and while making it, calls the init again,

which tries to make ANOTHER Bucky object,
which calls init again,

and so on. You get the picture.

I think you just want:

  size = (300,200)

···

On Thursday, February 19, 2015 at 1:13:24 PM UTC-5, Anonym wrote:

import wx



class Bucky(wx.Frame):
    def __init__(self, parent, id):
        wx.Frame.__init__(self, parent, id, 'Frame aka window', size=Bucky(300, 200))


if __name__ == '__main__':
    app = wx.PySimpleApp()
    frame = Bucky(parent=None, id=-1)
    frame.show()
    app.MainLoop()





when this code is run 'maximum recursion depth exceeded' error pops up and the code terminates. Any solution?