from tkinter import *
from tkinter import messagebox as g
import pickle
import random
# from PIL import Image, ImageTk
# password = 'python'
# pickle_file = open('./password.pkl','wb')
# pickle.dump(password,pickle_file)
# pickle_file.close()
pickle_file = open(r".\password.pkl","rb")
password = pickle.load(pickle_file)
ci_shu = 0
tk = Tk()
tk.title('账号登陆')
tk.geometry('400x450')
system = StringVar(value='flat') # FLAT
var = StringVar(value='Administrator')
var1 = StringVar(value='')
def enter(ev = None):
system.set('ridge') #RIDGE
def leave(ev = None):
system.set('flat')
def yan_zheng(ev = None):
zhang_hao_get = zhang_hao.get()
mi_ma_get = mi_ma.get()
if zhang_hao_get == 'Administrator' and mi_ma_get == password:
g.showinfo('', '登录成功')
tk.destroy()
else:
var1.set('')
g.showerror('', '用户名或密码错误')
ci_shu + 1
def chongzhi():
var1.set('')
var.set('Administrator')
# img_gif = PhotoImage(file = r'C:\Users\Administrator\Desktop\apple.gif')
# button_img = Button(root, image = img_gif, text = '带图按钮')
# button_img.pack()
Label(tk, text='账号', font=('楷书', 20)).place(x=10, y=10)
zhang_hao = Entry(tk, fg='blue', font=('楷书', 20), textvariable=var)
zhang_hao.place(x=70 ,y=10)
zhang_hao.bind('<Return>', yan_zheng)
Label(tk, text='密码', font=('楷书', 20)).place(x=10, y=50)
mi_ma = Entry(tk, fg='blue', font=('楷书', 20) ,show='●', textvariable=var1)
mi_ma.place(x=70, y=50)
mi_ma.bind('<Return>', yan_zheng)# redge
deng_lu = Button(tk, text='登录', fg='blue', font=('楷书', 20) ,command=yan_zheng)# RIDGE , relief=syst
deng_lu.place(x=10, y=100)
deng_lu.bind("<Enter>", enter)
deng_lu.bind("<Leave>", leave)
chong_zhi = Button(tk, text='重置', fg='blue', font=('楷书', 20), command=chongzhi)
chong_zhi.place(x=120, y=100)
tk.mainloop()