-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetuserinput.py
More file actions
41 lines (40 loc) · 1.54 KB
/
getuserinput.py
File metadata and controls
41 lines (40 loc) · 1.54 KB
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
from Tkinter import *
import main
import os
import settings
# Opens a popup where users can enter username, password etc.
# Saves the details in secrets file
def enter():
print 'Your credentials do not exist'
root = Tk()
root.title('Authentication System')
Label(text='Username').pack(side=TOP,padx=30,pady=10)
username_input = Entry(root, width=30)
username_input.pack(side=TOP,padx=10,pady=10)
Label(text='Password').pack(side=TOP,padx=30,pady=10)
password_input = Entry(root,show="*",width=30)
password_input.pack(side=TOP,padx=10,pady=10)
def onok():
# Takes directory details from settings and creates them if they do not exist
directory_1=settings.main_dir
directory_2=settings.main_dir_hidden
if not os.path.exists(directory_1):
os.makedirs(directory_1)
if not os.path.exists(directory_2):
os.makedirs(directory_2)
#
username = username_input.get()
password = password_input.get()
secrets_file = settings.secrets_file
f = open(secrets_file, "w")
f.write(username+'\n') # python will convert \n to os.linesep
f.write(password+'\n') # python will convert \n to os.linesep
f.write(directory_1+'\n')
f.close() # you can omit in most cases as the destructor will call if
root.destroy()
main.main_func()
def onclose():
exit()
Button(root, text='OK', command=onok).pack(side=LEFT)
Button(root, text='CLOSE', command=onclose).pack(side= RIGHT)
root.mainloop()