Python Tkinter - Recursionerror: Maximum Recursion Depth Exceeded While Calling A Python Object
Solution 1:
The problem, or at least one problem, is that you are calling mainloop
more than once, and you are calling it from an event handler. That is what is ultimately causing your infinite recursion.
As the name implies, mainloop
is an infinite loop itself. It runs until the main window is destroyed. When you press a key or button, mainloop
is what runs the command associated with the key or button. If that command is MinePressed
, it will eventually cause mainloop
to be called again from inside the original call to mainloop
.
Because mainloop
never exits (because the root window is never destroyed), you have an infinite loop calling an infinite loop calling an infinite loop, ..., and none of those inner loops ever exit. Eventually you run out of stack space when you get a thousand copies of mainloop
running.
You need to move root.mainloop()
out of MinePressed
and put it as the last line in your file, e.g.:
SelectSize()
input()
root.mainloop()
Though, maybe it goes before input()
-- I have no idea what that line of code is for.
Post a Comment for "Python Tkinter - Recursionerror: Maximum Recursion Depth Exceeded While Calling A Python Object"