MCPcopy Create free account
hub / github.com/MorvanZhou/tutorials / usr_login

Function usr_login

tkinterTUT/tk14_login_example/tk14_login_example.py:31–50  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29entry_usr_pwd.place(x=160, y=190)
30
31def usr_login():
32 usr_name = var_usr_name.get()
33 usr_pwd = var_usr_pwd.get()
34 try:
35 with open('usrs_info.pickle', 'rb') as usr_file:
36 usrs_info = pickle.load(usr_file)
37 except FileNotFoundError:
38 with open('usrs_info.pickle', 'wb') as usr_file:
39 usrs_info = {'admin': 'admin'}
40 pickle.dump(usrs_info, usr_file)
41 if usr_name in usrs_info:
42 if usr_pwd == usrs_info[usr_name]:
43 tk.messagebox.showinfo(title='Welcome', message='How are you? ' + usr_name)
44 else:
45 tk.messagebox.showerror(message='Error, your password is wrong, try again.')
46 else:
47 is_sign_up = tk.messagebox.askyesno('Welcome',
48 'You have not sign up yet. Sign up today?')
49 if is_sign_up:
50 usr_sign_up()
51
52def usr_sign_up():
53 pass

Callers

nothing calls this directly

Calls 1

usr_sign_upFunction · 0.70

Tested by

no test coverage detected