print("ok")print("usr_name:",usr_name)if usr_name in usrs_info:print("3")if usr_pwd == usrs_info[usr_name]:
tk.messagebox.showinfo(title="Welcome",message="How are you"+usr_name)
tk.messagebox.showinfo(title="Game Start", message="Let's start the game!")
subprocess.run(["python","井字棋.py"])else:
tk.messagebox.showerror(message="Error,your password is wrong,try again.")else:print("4")
is_sign_up = tk.messagebox.askyesno(title="Welcome",message="You have not sign up yet.sign up today?")
注册功能实现
defsign_up():
nn = entry9.get()
np = entry10.get()
npf = entry11.get()withopen('usrs_info.pickle','rb')as usr_file:
exist_usr_info = pickle.load(usr_file)if np != npf:
tk.messagebox.showerror("Error","The user has already signed up!")elif nn in exist_usr_info:print("已经注册过了")
tk.messagebox.showerror("Error","The user has already signed up!")else:
exist_usr_info[nn]= np
withopen("usrs_info.pickle","wb")as usr_file:
pickle.dump(exist_usr_info,usr_file)
tk.messagebox.showinfo("Welcome","You have successfully signed up!")
window.destroy()
button3 = tk.Button(window, text='Sign up', width=10,command=sign_up)
button3.place(x=140, y=150)print("开始注册")