forked from kelhuynh/SFWRENG-3K04-Pacemaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testGui.py
55 lines (44 loc) · 1.87 KB
/
testGui.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
49
50
51
52
53
54
55
import tkinter as tk
from tkinter import ttk
from login import Login, Register
from modeInterface import Mode
class MainWindow:
# Pacemaker DCM main menu class
def __init__(self):
# Initialization of main menu
self.app = tk.Tk()
self.app.title("Pacemaker DCM Main Menu")
self.app.geometry("300x200")
self.label = tk.Label(self.app, text="Welcome to the Pacemaker UI")
self.label.place(x=65, y=40)
self.loginButton = tk.Button(self.app, text="Login", pady=5, padx=20, command=self.login)
self.loginButton.place(x=107, y=60)
self.regButton = tk.Button(self.app, text="Register", pady=5, padx=20, command=self.register)
self.regButton.place(x=100, y=100)
def login(self):
# Method that triggers login window from the Login class
# Note: loginTk becomes a property of the MainWindow object, required in other methods to check for successful login
self.app.iconify()
self.loginTk = Login()
self.loginTk.run()
def register(self):
# Method that triggers register window from the Register class
# Note: lack of self on regTk because it isn't required to interact with anything else in the MainWindow class
self.app.iconify()
regTk = Register()
regTk.run()
def checkUserLogin(self):
# Method constantly checks for a successful user log in before opening interface window
try:
if not self.loginTk.loggedIn():
self.app.after(1000, self.checkUserLogin)
else:
menuSelect = Mode(self.loginTk.currentUser())
menuSelect.run()
except AttributeError:
self.app.after(1000, self.checkUserLogin)
def run(self):
self.app.after(3000, self.checkUserLogin)
self.app.mainloop()
app = MainWindow()
app.run()