【发布时间】:2021-07-07 00:49:53
【问题描述】:
我试图阻止主窗口运行,直到在单独的顶层窗口上按下按钮。
例子:
from tkinter import *
let_user_through = False
window = Tk()
def activate_main_window():
global let_user_through
let_user_through = True
frame = Toplevel()
b = Button(frame, text="Enter", command=activate_main_window).pack()
if let_user_through == True:
lbl = Label(window, text="Hello")
#bunch of code
#bunch of code
window.mainloop()
在这个例子中,在主窗口中有一个标签,上面写着:“你好”。 但我不希望人们如果没有按下框架上的按钮就可以看到它
一旦用户按下按钮,框架将自行销毁,主窗口将继续执行一堆代码。
我是 tkinter 的初学者,所以我不确定答案是否显而易见。谢谢!
【问题讨论】: