-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.py
48 lines (39 loc) · 1.37 KB
/
main.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
42
43
44
45
46
47
48
import tkinter.messagebox
from tkinter import *
from file_share.app.init_app import is_first_init, first_init_app, init_app
config = {"visible": True, "audible": True}
def main():
login_window = Tk()
login_window.title("Login Window")
is_this_first_init = is_first_init()
if is_this_first_init:
username_label = Label(login_window, text="Choose username:")
username_label.pack()
username_entry = Entry(login_window)
username_entry.pack()
password_label = Label(login_window, text="Password:")
password_label.pack()
password_entry = Entry(login_window, show="*")
password_entry.pack()
def start_app():
try:
if is_this_first_init:
fs_app = first_init_app(
username_entry.get(), password_entry.get(), config
)
else:
fs_app = init_app(password_entry.get(), config)
except ValueError:
message = tkinter.messagebox.Message(
message="Invalid password!", icon=tkinter.messagebox.ERROR
)
message.show()
return
login_window.destroy()
fs_app.start()
fs_app.stop()
login_button = Button(login_window, text="Login", command=(lambda: start_app()))
login_button.pack()
login_window.mainloop()
if __name__ == "__main__":
main()