登录窗口###python,tkinter,pickle
import tkinter as tk
from tkinter import messagebox
import pickle
window=tk.Tk()
window.title(‘login’)
window.geometry(‘400x200’)
l1=tk.Label(window,text=‘name:’,bg=‘red’,width=5)
l2=tk.Label(window,text=‘key:’,bg=‘red’,width=5)
l1.place(x=10,y=10)
l2.place(x=10,y=50)
var1=tk.StringVar()
var2=tk.StringVar()
e1=tk.Entry(window,show=None,textvariable=var1)
e2=tk.Entry(window,show=None,textvariable=var2)
e1.place(x=60,y=10)
e2.place(x=60,y=50)
f=open(‘dianhua.pickel’,‘wb’)
Dict={‘a’:111,‘b’:222,‘c’:333}
pickle.dump(Dict,f,True)
f.close()
def ok():
v1=var1.get()
v2=int(var2.get())
if v1 in Dict:
if v2==Dict.get(v1):
tk.messagebox.showinfo(message=‘sussess1’)
else:
tk.messagebox.showerror(message=‘error1’)
else:
tk.messagebox.showerror(message=‘error1’)
b=tk.Button(window,text=‘OK’,command=ok)
b.place(x=50,y=90)
window.mainloop()