这是一个简单的登录屏幕。我不知道这有什么问题。当我点击登录时,什么也没有发生。请指教。from tkinter import *from tkinter import messageboxwindow = Tk()window.title("PyOS")window.geometry('1000x500')user = Label(window,text="Username")pass1 = Label(window,text="Password")login = Button(window,text="Login")def clicked(login): wrong = Label(window,text="Wrong Password") wrong.grid(column=1,row=2)userentry = Entry(window,font="Sanserif",width=30)passentry = Entry(window,font="Marlett",show="n",width=17)userentry.grid(column=1, row=0)passentry.grid(column=1, row=1)user.grid(column=0, row=0)pass1.grid(column=0, row=1)login.grid(column=0, row=2)window.mainloop()
1 回答
慕神8447489
TA贡献1780条经验 获得超1个赞
您需要告诉按钮在按下时执行哪个功能。这是通过使用commandButton的参数来完成的。
from tkinter import *
from tkinter import messagebox
window = Tk()
window.title("PyOS")
def clicked():
wrong = Label(window,text="Wrong Password")
wrong.grid(column=1,row=2)
user = Label(window,text="Username")
pass1 = Label(window,text="Password")
login = Button(window,text="Login", command=clicked)
userentry = Entry(window,font="Sanserif")
passentry = Entry(window,font="Marlett", show="*")
userentry.grid(column=1, row=0)
passentry.grid(column=1, row=1)
user.grid(column=0, row=0)
pass1.grid(column=0, row=1)
login.grid(column=0, row=2)
window.mainloop()
添加回答
举报
0/150
提交
取消