【发布时间】:2019-11-06 00:12:11
【问题描述】:
当我单击按钮转到下一个窗口时,我正在尝试关闭上一个窗口。我做不到。怎么了?
from tkinter import *
def newwindow2():
newwindow.destroy()
newwindow2 = tk.Toplevel()
newwindow2.title('Nível da grama região 3')
newwindow2.geometry('580x520')
labl3 = Label(newwindow2, text='A foto do nível da grama na região 3 foi tirada: \n', font=30).place(x=110, y=10)
tk.Button(newwindow2, text='Fim').place(x=250, y=470)
def newwindow():
janela1.destroy()
newwindow = tk.Toplevel()
newwindow.title('Nível da grama região 2')
newwindow.geometry('580x520')
labl2 = Label(newwindow, text='A foto do nível da grama na região 2 foi tirada: \n', font=30).place(x=110, y=10)
tk.Button(newwindow, text='Próximo', command=newwindow2).place(x=250, y=470)
janela1 = tk.Tk()
janela1.title('Nível da grama região 1')
janela1.geometry("580x520")
labl1=Label(janela1, text='A foto do nível da grama na região 1 foi tirada: ',font=30).place(x=110, y=10)
tk.Button(janela1, text='Próximo', command=newwindow).place(x=250, y=470)
janela1.mainloop()
如您所见,我正在尝试使用 .destroy() 但它不起作用。有什么解决办法吗?我刚开始学习 Python,所以我知道这可能非常简单。感谢您的帮助!
【问题讨论】:
标签: python python-3.x tkinter toplevel