#πŸ”’ maximum recursion depth exceeded (tkinter help)

6 messages Β· Page 1 of 1 (latest)

glass agate
#

this is the full tracebackpy Traceback (most recent call last): File "/home/duomg/Documents/other_python/tk_.py", line 13, in <module> App().mainloop() File "/home/duomg/Documents/other_python/tk_.py", line 9, in __init__ tk.Button(master=self, text=num).grid(row=i, column=j) File "/home/duomg/apps/thonny/lib/python3.10/tkinter/__init__.py", line 2679, in __init__ Widget.__init__(self, master, 'button', cnf, kw) File "/home/duomg/apps/thonny/lib/python3.10/tkinter/__init__.py", line 2595, in __init__ self._setup(master, cnf) File "/home/duomg/apps/thonny/lib/python3.10/tkinter/__init__.py", line 2564, in _setup self.tk = master.tk File "/home/duomg/apps/thonny/lib/python3.10/tkinter/__init__.py", line 2383, in __getattr__ return getattr(self.tk, attr) File "/home/duomg/apps/thonny/lib/python3.10/tkinter/__init__.py", line 2383, in __getattr__ return getattr(self.tk, attr) File "/home/duomg/apps/thonny/lib/python3.10/tkinter/__init__.py", line 2383, in __getattr__ return getattr(self.tk, attr) [Previous line repeated 990 more times] RecursionError: maximum recursion depth exceeded and this is my code```py
import tkinter as tk

class App(tk.Tk):
def init(self, /):
for i in range(3):
for j in range(3):
num = 3 * (2 - i) + j + 1
tk.Button(master=self, text=num).grid(row=i, column=j)

if name == 'main':
App().mainloop()

elder bronzeBOT
#

@glass agate

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

leaden wind
#

I think it's because you're sublassing Tk. You might want to subclass Frame instead

glass agate
#

so like this```py
import tkinter as tk

class App(tk.Frame):
def init(self, *args, **kwargs):
super().init(*args, **kwargs)
for i in range(3):
for j in range(3):
num = 3 * (2 - i) + j + 1
tk.Button(master=self, text=num).grid(row=i, column=j)

if name == 'main':
root = tk.Tk()
App(root).pack()
root.mainloop()

elder bronzeBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.