-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcredentials.py
executable file
·41 lines (39 loc) · 1.24 KB
/
credentials.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python3
"""
Module to create dialogue box to obtain password from the user and
create an instance in Keychain and save the password in that
instance
"""
import tkinter as tk
import keyring
def make_entry(parent, caption, width=None, **options):
tk.Label(parent, text=caption).pack(side=tk.TOP)
entry = tk.Entry(parent, **options)
if width:
entry.config(width=width)
entry.pack(side=tk.TOP, padx=10, fill=tk.BOTH)
return entry
def enter(event):
check_password()
def check_password():
if (user.get() == password.get()):
keyring.set_password("MacFace", "Account-name", password.get())
root.title('Recorded')
return
else:
root.title('Try again')
root = tk.Tk()
root.geometry('300x160')
root.title('Password Request')
#frame for window margin
parent = tk.Frame(root, padx=10, pady=10)
parent.pack(fill=tk.BOTH, expand=True)
#entrys with hidden text
user = make_entry(parent, "Password:", 16, show='*')
password = make_entry(parent, "Confirm Password:", 16, show="*")
#button to enter the password
b = tk.Button(parent, borderwidth=4, text="OK", width=10, pady=8, command=check_password)
b.pack(side=tk.BOTTOM)
password.bind('<Return>', enter)
user.focus_set()
parent.mainloop()