我正在尝试编写一个非常小的应用程序,它应该从一个窗口开始,在这个窗口中你可以输入密码,并且可以正常工作。之后,它会打开另一个窗口,要求提供将进入文件(尚未开发!)的凭证。 我的问题是,我无法从第二个窗口中的第二个文本小部件获取值。有人能帮我吗
代码如下:
from tkinter import *
import tkinter as tk
root=Tk()
root.geometry("400x400")
root.title("password test")
def getNewWindow():
root2 = tk.Tk()
root2.geometry("200x200")
root2.title("infos")
textBox2=Text(root2, height=2, width=10)
textBox2.pack()
def retrieve_input2():
inputValue2=textBox2.get("1.0","end-1c")
if inputValue2 == "110604":
pass
buttonCommit=Button(root2, height=1, width=10, text="Commit",
command=lambda: retrieve_input2())
buttonCommit.pack()
def retrieve_input():
inputValue=textBox.get("1.0","end-1c")
if inputValue == "110604":
getNewWindow()
textBox=Text(root, height=2, width=10)
textBox.pack()
buttonCommit=Button(root, height=1, width=10, text="Commit",
command=lambda: retrieve_input())
#command=lambda: retrieve_input() >>> just means do this when i press the button
buttonCommit.pack()
mainloop()
目前没有回答
相关问题 更多 >
编程相关推荐