-
Notifications
You must be signed in to change notification settings - Fork 1
/
gui.py
88 lines (61 loc) · 2.25 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# visual part of the app shows window with play and quit buttons
# by oran collins
# github.com/wisehackermonkey
# 20200419
import tkinter as tk
import threading
import sys
import os
# location of server address, app version number
from client_config import ClientConfig
import pkg_resources.py2_warn
# download and update app to new version
from update import check_for_update
# class uses threading to isolate
# the tkinter mainloop from my tts loop
class App(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.start()
def close_window(self):
self.root.quit()
def play_tts(self):
print("Playing")
def restart(self):
"""Restarts the current program.
Note: this function does not return. Any cleanup action (like
saving data) must be done before calling this function."""
print("Stopping")
python = sys.executable
os.execl(python, python, * sys.argv)
def run(self):
self.root = tk.Tk()
# start application minimized
self.root.iconify()
# set window name
self.root.title("Ultimate TTS Reader")
#set minimum window size
self.root.minsize(275,50)
# setup quit callback on windows close
self.root.protocol("WM_DELETE_WINDOW", self.close_window)
# Title text
label = tk.Label(self.root, text="Ultimate TTS Reader")
label.pack()
# TODO add pause button
# Stop button
button = tk.Button(self.root, justify="center", text="Stop", command=self.restart)
button.pack()
# Update app button
self.menubar = tk.Menu(self.root)
self.filemenu = tk.Menu(self.root,tearoff=0)
self.filemenu.add_command(label="Update", command=check_for_update)
self.filemenu.add_command(label="Exit", command=self.close_window)
self.menubar.add_cascade(label="Options", menu=self.filemenu)
# display the menu
self.root.config(menu=self.menubar)
# Quit button
self.quit = tk.Button(self.root, text="Quit", command=self.root.quit)
self.quit.pack(side="bottom")
# Start of threaded main tkinter loop
self.root.mainloop()