
window = tk.Tk() |
window.title('欢迎使用登录系统') |
window.geometry('400x300') |
def 条款声明(): |
tkinter.messagebox.showinfo(title='条框声明(1)',message='1.此作品是heroy原创哦') |
tkinter.messagebox.showinfo(title='条框声明(2)',message='2.我的qq号为2101177878') |
tkinter.messagebox.showinfo(title='条框声明(3)',message='3.祝大家玩的开心!!!') |
def 退出(): |
go_back = tkinter.messagebox.askyesno('提示', '你要退出吗?') |
if go_back: |
window.destroy() |
def 加qq(): |
go_back = tkinter.messagebox.askyesno('提示', '你要加我qq吗?') |
if go_back: |
os.system('qq.bat') |
menubar = tk.Menu(window) |
filemenu = tk.Menu(menubar, tearoff=0) |
menubar.add_cascade(label='退出(quit)', command=退出) |
menubar.add_cascade(label='加我qq(quick)', command=加qq) |
window.config(menu=menubar) |
canvas = tk.Canvas(window, width=400, height=135, bg='green') |
image_file = tk.PhotoImage(file='pic.gif') |
image = canvas.create_image(200, 0, anchor='n', image=image_file) |
canvas.pack(side='top') |
tk.Label(window, text='欢迎使用heroy登录系统',font=('Arial', 16)).pack() |
tk.Label(window, text='用户名:', font=('Arial', 14)).place(x=10, y=170) |
tk.Label(window, text='密码:', font=('Arial', 14)).place(x=10, y=210) |
var_usr_name = tk.StringVar() |
entry_usr_name = tk.Entry(window, textvariable=var_usr_name, font=('Arial', 14)) |
entry_usr_name.place(x=120,y=175) |
var_usr_pwd = tk.StringVar() |
entry_usr_pwd = tk.Entry(window, textvariable=var_usr_pwd, font=('Arial', 14), show='*') |
entry_usr_pwd.place(x=120,y=215) |
def usr_login(): |
usr_name = var_usr_name.get() |
usr_pwd = var_usr_pwd.get() |
try: |
usr_file.close() |
if usr_name in usrs_info: |
if usr_pwd == usrs_info[usr_name]: |
tkinter.messagebox.showinfo(title='欢迎', message='你好! ' + usr_name) |
else: |
tkinter.messagebox.showerror(title='提示',message='错误:您的密码错误,请重试.') |
else: |
np = new_pwd.get() |
npf = new_pwd_confirm.get() |
nn = new_name.get() |
with open('usrs_info.pickle', 'rb') as usr_file: |
exist_usr_info = pickle.load(usr_file) |
if np != npf: |
tkinter.messagebox.showerror('提示', '错误:密码与确认密码必须相同!') |
elif nn in exist_usr_info: |
tkinter.messagebox.showerror('提示', '错误:用户已经注册!') |
else: |
|
tk.Label(window_sign_up, text='密码: ').place(x=10, y=50) |
entry_usr_pwd = tk.Entry(window_sign_up, textvariable=new_pwd, show='*') |
entry_usr_pwd.place(x=130, y=50) |
|
new_pwd_confirm = tk.StringVar() |
tk.Label(window_sign_up, text='确认密码: ').place(x=10, y=90) |
entry_usr_pwd_confirm = tk.Entry(window_sign_up, textvariable=new_pwd_confirm, show='*') |
entry_usr_pwd_confirm.place(x=130, y=90) |
btn_comfirm_sign_up = tk.Button(window_sign_up, text='注册(Sign up)', command=sign_to_Hongwei_Website) |
btn_comfirm_sign_up.place(x=180, y=120) |
btn_login = tk.Button(window, text='登录(Login)', command=usr_login) |
btn_login.place(x=80, y=250) |
btn_sign_up = tk.Button(window, text='注册(Sign up)', command=usr_sign_up) |
btn_sign_up.place(x=240, y=250) |
btn_sign_up = tk.Button(window, text='条款声明', command=条款声明) |
btn_sign_up.place(x=170, y=250) |
window.mainloop() |




by: 发表于:2020-09-05 14:32:15 顶(2) | 踩(1) 回复
厉害了
回复评论