Превышены лимиты рекурсии
Я ломал голову, искал ответ, но не нашёл.
Я знаю, что mainloop()
превращается в цикл, который вызывает цикл и т.д.
Но как это решить?
class login(Tk):
def __init__(self):
self.geometry('900x600')
self.resizable(width=False, height=False)
self.title('1')
#bar
frame_photo = PhotoImage(file = 'images/menu.png')
frame_lable = Label(self, image = frame_photo)
frame_lable.pack()
def started_reg():
self.withdraw()
registration()
#image list
button_image_log = PhotoImage(file = 'images/button_log.png')
button_image_reg = PhotoImage(file = 'images/button_reg.png')
#buttons
create_button_1 = Button(self,
image = button_image_log,
border = 0,
bg = rgb((255,255,255)),
#command = clicked_log,
activebackground = rgb((255,255,255)))
create_button_1.place(x = 522, y = 410)
create_button_2 = Button(self,
image = button_image_reg,
border = 0,
bg = rgb((255,255,255)),
command = started_reg(),
activebackground = rgb((255,255,255)))
create_button_2.place(x = 522, y = 464)
#boxEntry
login = Entry(self,
font = ('Golos Text Regular', 15),
bg = rgb((232, 232, 232)),
width = 25,
borderwidth=0)
login.place(x = 529, y = 218)
passwsord = Entry(self,
font = ('Golos Text Regular', 15),
bg = rgb((232, 232, 232)),
width = 25,
borderwidth=0)
passwsord.place(x = 529, y = 314)
startedlogin = login()
startedlogin.mainloop()
Ответы (1 шт):
Автор решения: S. Nick
→ Ссылка
Примерно так:
from tkinter import *
class Login(Frame): # +++ Login(Frame)
def __init__(self, master): # +++ master
super().__init__(master) # +++ master
self.frame_photo = PhotoImage(file = 'boy33.png')
frame_lable = Label(self, image = self.frame_photo)
frame_lable.pack()
def started_reg():
print(f'def started_reg(): ????????????') #
# ??? self.withdraw()
# ??? registration()
# ------------> vvvv
self.button_image_log = PhotoImage(file = 'Ok.png')
self.button_image_reg = PhotoImage(file = 'Ok.png')
# ------------> ^^^^
create_button_1 = Button(self,
image = self.button_image_log,
border = 0,
bg = '#ccc',
#command = clicked_log,
activebackground = '#ff0')
create_button_1.place(x = 522, y = 410)
create_button_1.pack() # +++
create_button_2 = Button(self,
image = self.button_image_reg,
border = 0,
bg = '#f0f',
# command = started_reg(),
# -----------------------------------------> v^^ <--------------------------
command = started_reg,
activebackground = '#ff0')
create_button_2.place(x = 522, y = 464)
create_button_2.pack() # +++
login = Entry(self,
font = ('Golos Text Regular', 15),
bg = '#fff',
width = 25,
borderwidth=0)
login.place(x = 529, y = 218)
login.pack() # +++
passwsord = Entry(self,
font = ('Golos Text Regular', 15),
bg = '#fff',
width = 25,
borderwidth=0)
passwsord.place(x = 529, y = 314)
passwsord.pack() # +++
#vvv
root = Tk() # +++
root.geometry('900x600') # +++
#root.resizable(width=False, height=False) # +++
root.title('title 1') # +++
# -----------> vvvvvvvvvv
startedlogin = Login(root)
startedlogin.pack()
#vvv
root.mainloop()
