parent
0c6941f5b4
commit
1e9d533d75
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="PySciProjectComponent">
|
||||
<option name="PY_INTERACTIVE_PLOTS_SUGGESTED" value="true" />
|
||||
</component>
|
||||
</project>
|
Binary file not shown.
@ -1,57 +0,0 @@
|
||||
from tkinter import *
|
||||
|
||||
user_login = {
|
||||
'aaa': '123',
|
||||
'bbb': '654'
|
||||
}
|
||||
|
||||
count = 0
|
||||
|
||||
def temp(s):
|
||||
win = Tk()
|
||||
win.geometry('100x100')
|
||||
|
||||
message = Label(win, text=s)
|
||||
message.pack()
|
||||
|
||||
def login() :
|
||||
global count
|
||||
username = entry_username.get()
|
||||
if username not in user_login:
|
||||
label_message.config(text='账号错误')
|
||||
else:
|
||||
password = entry_password.get()
|
||||
if password == user_login[username]:
|
||||
#label_message.config(text='登录成功')
|
||||
temp('登录成功')
|
||||
|
||||
else:
|
||||
label_message.config(text='密码错误!还可以尝试{}次'.format(2 - count))
|
||||
count += 1
|
||||
if count == 3:
|
||||
temp('登陆失败')
|
||||
btn_login.config(state='disabled')
|
||||
|
||||
windon = Tk()
|
||||
windon.title('用户登录')
|
||||
windon.geometry('300x200')
|
||||
|
||||
label_username = Label(windon, text='账号')
|
||||
label_username.pack()
|
||||
|
||||
entry_username = Entry(windon)
|
||||
entry_username.pack()
|
||||
|
||||
label_password = Label(windon, text='密码')
|
||||
label_password.pack()
|
||||
|
||||
entry_password = Entry(windon, show='*')
|
||||
entry_password.pack()
|
||||
|
||||
btn_login = Button(windon, text='登录', command=login)
|
||||
btn_login.pack()
|
||||
|
||||
label_message = Label(windon, text="")
|
||||
label_message.pack()
|
||||
|
||||
windon.mainloop()
|
Loading…
Reference in new issue