forked from GeorgeCiesinski/text-script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gui.py
60 lines (38 loc) · 1.04 KB
/
Gui.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
56
57
58
59
60
import tkinter
from Logger import Logger
class Gui:
def __init__(self, log):
# Instance wide log variable
self.log = log.log
# Instance wide root variable
self.root = None
# Creates a new window
self.create_window()
# TODO: Create menu
def create_window(self):
"""
create_window creates a new tkinter window including basic setup
"""
# Main tkinter window
self.root = tkinter.Tk()
# Window Setup
self.root.title("Text-Script")
self.root.geometry("200x200")
self.log.debug("Successfully created a new window.")
def on_closing(self):
"""
Closes program if user clicks x button on the window
"""
self.log.debug("User clicked the window's x button. Exiting program.")
self.root.destroy()
if __name__ == "__main__":
# Initialize Logger
L = Logger()
L.log.debug("Program started from Gui.py.")
# Initialize GUI
g = Gui(L)
# Close program if window is destroyed
g.root.protocol("WM_DELETE_WINDOW", g.on_closing)
# Tkinter mainloop
L.log.debug("Starting Tkinter mainloop.")
g.root.mainloop()