|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
代码import tkinter as tk
import tkinter.messagebox
win=tk.Tk()
win.title("用户登录")
win.geometry("250x130")
var_Name=tk.StringVar()
var_Name.set('')
var_Pwd=tk.StringVar()
var_Pwd.set('')
def login():
name=var_Name.get()
pwd=var_Pwd.get()
if name=='admin' and pwd=='python@16':
tk.messagebox.showinfo(title='用户登录',message='成功!')
else:
tk.messagebox.showinfo(title='用户登录',message='失败!')
def cancel():
var_Name.set('')
var_Pwd.set('')
def _quit():
win.quit()
win.destory()
labname=tk.Label(win,text='账号:',width=80)
labpwd=tk.Label(win,text='密码:',width=80)
entname=tk.Entry(win,width=100,textvariable=var_Name)
entpwd=tk.Entry(win,show='*',width=100,textvariable=var_Pwd)
but_Ok=tk.Button(win,text='登录',command=login)
but_Cancel=tk.Button(win,text='重置',command=cancel)
but_quit=tk.Button(win,text='退出',command=_quit)
labname.place(x=20,y=10,width=80,height=20)
labpwd.place(x=20,y=40,width=80,height=20)
entname.place(x=120,y=10,width=80,height=20)
entpwd.place(x=120,y=40,width=80,height=20)
but_Ok.place(x=30,y=80,width=50,height=20)
but_Cancel(x=1000,y=80,width=50,height=20)
but_quit.place(x=170,y=80,width=50,height=20)
win.mainloop()
帮我修改一下
import tkinter as tk
import tkinter.messagebox
win=tk.Tk()
win.title("用户登录")
win.geometry("250x130")
var_Name=tk.StringVar()
var_Name.set('')
var_Pwd=tk.StringVar()
var_Pwd.set('')
def login():
name=var_Name.get()
pwd=var_Pwd.get()
if name=='admin' and pwd=='python@16':
tk.messagebox.showinfo(title='用户登录',message='成功!')
else:
tk.messagebox.showinfo(title='用户登录',message='失败!')
def cancel():
var_Name.set('')
var_Pwd.set('')
def _quit():
win.quit()
win.destroy() # 修改
labname=tk.Label(win,text='账号:',width=80)
labpwd=tk.Label(win,text='密码:',width=80)
entname=tk.Entry(win,width=100,textvariable=var_Name)
entpwd=tk.Entry(win,show='*',width=100,textvariable=var_Pwd)
but_Ok=tk.Button(win,text='登录',command=login)
but_Cancel=tk.Button(win,text='重置',command=cancel)
but_quit=tk.Button(win,text='退出',command=_quit)
labname.place(x=20,y=10,width=80,height=20)
labpwd.place(x=20,y=40,width=80,height=20)
entname.place(x=120,y=10,width=80,height=20)
entpwd.place(x=120,y=40,width=80,height=20)
but_Ok.place(x=30,y=80,width=50,height=20)
but_Cancel.place(x=100,y=80,width=50,height=20) # 修改
but_quit.place(x=170,y=80,width=50,height=20)
win.mainloop()
|
|