Maximum recursion depth exceeded in wxPython

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Maximum recursion depth exceeded in wxPython

Anonym-2
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 received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Maximum recursion depth exceeded in wxPython

Mike Driscoll


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?

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

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Maximum recursion depth exceeded in wxPython

Rufus V. Smith
In reply to this post by Anonym-2
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?

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.