我试图在打印内容之前让我的 tkinter 顶层有一个访问密钥。它不会输出任何错误但是当我提供访问密钥时它不会将内容打印到我的终端。我更改了访问密钥但是我仍然无法打印数据。
从 tkinter 导入 *
def qw():
global en1
if en1.get() == 2e2c2v:
print("You have visa to Paris")
tp.destroy() # after printing should close the toplevel window
else:
print("you dont have access to print the data")
def login_toplevel():
global en1
tp = Toplevel()
tp.geometry("300x300")
en1 = Entry(tp)
en1.pack()
b = Button(tp, text="provide key to print", command=qw)
b.pack()
root = Tk()
root.geometry("400x400")
b = Button(root, text= "print", command=login_toplevel).pack()
root.mainloop()