Кнопка, создаваемая внутри функции не принимает как команду функцию, создаваемую внутри этой же функции. Как исправить? Непосредственно код:
from tkinter import *
#test1 - самооценка
#test2 - приятно ли с вами общаться
#test3 - благоразумие
root = Tk()
root.title("Психологический тест")
root.geometry('700x700')
def test1_fun():
def test1_shutdown():
test1.destroy()
test1 = Tk()
test1.title("Тест 1. Уровень Вашей самооценки")
test1.geometry('500x500')
test1_descr = Label(test1, text="Вы готовы пройти тест из 15 вопросов?", font="Arial 20", background="gray93", justify=CENTER)
test1_descr.place(relx=0, rely=0.3, relwidth=1, relheight=0.1)
test1_ready = Button(test1, text="Да", background="gray90", font="Arial 16")
test1_notready = Button(test1, text="Нет", background="gray90", font="Arial 16")
test1_ready.place(relx=0.73, rely=0.7, relwidth=0.15, relheight=0.1)
test1_notready.place(relx=0.1, rely=0.7, relwidth=0.15, relheight=0.1, command=test1_shutdown)
choose_lab = Label(root, text="Выберите тест", width=30, height=1, font="Arial 20", background="gray93")
choose_lab.place(x=100, y=1)
test1_but = Button(root, text="Уровень Вашей самооценки.", width=30, height=2, font="Arial 20", background="gray90", command=test1_fun)
test1_but.place(x=100, y=180)
test2_but = Button(root, text="Приятно ли с Вами общаться?", width=30, height=2, font="Arial 20", background="gray90")
test2_but.place(x=100, y=380)
test3_but = Button(root, text="Благоразумны ли Вы?", width=30, height=2, font="Arial 20", background="gray90")
test3_but.place(x=100, y=580)
root.mainloop()
Текст ошибки(сама кнопка с этой ошибкой не создаётся):
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\clash\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 1921, in __call__
return self.func(*args)
File "C:\Users\clash\PycharmProjects\pythonProject\тест.py", line 19, in test1_fun
test1_notready.place(relx=0.1, rely=0.7, relwidth=0.15, relheight=0.1, command=test1_shutdown)
File "C:\Users\clash\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 2477, in place_configure
self.tk.call(
_tkinter.TclError: unknown option "-command"