1
|
|
|
from tkinter import * |
2
|
|
|
import time |
3
|
|
|
from lib.main import SpeedOfPi |
4
|
|
|
from tkinter.ttk import * |
5
|
|
|
|
6
|
|
|
|
7
|
|
|
class GUI(object): |
8
|
|
|
def __init__(self): |
9
|
|
|
self.game = SpeedOfPi() |
10
|
|
|
|
11
|
|
|
root = Tk() |
12
|
|
|
root.title('SpeedOfPi') |
13
|
|
|
|
14
|
|
|
# bring to front always |
15
|
|
|
root.lift() |
16
|
|
|
root.attributes('-topmost', True) |
17
|
|
|
|
18
|
|
|
# set full screen and not able to resize |
19
|
|
|
w, h = root.winfo_screenwidth(), root.winfo_screenheight() |
20
|
|
|
root.geometry("%dx%d+0+0" % (w, h)) |
21
|
|
|
root.resizable(width=False, height=False) |
22
|
|
|
|
23
|
|
|
self.frame = Frame(root, padding=(10, 10, 10, 10)) |
24
|
|
|
self.frame.pack() |
25
|
|
|
self.create_buttons() |
26
|
|
|
|
27
|
|
|
root.mainloop() |
28
|
|
|
|
29
|
|
|
def create_buttons(self): |
30
|
|
|
single_player_btn = Button(self.frame, text="Single Player", command=self.single_player) |
31
|
|
|
single_player_btn.pack(side="top", padx=10, pady=10) |
32
|
|
|
|
33
|
|
|
multi_player_btn = Button(self.frame, text="Multi Player", command=self.multi_player) |
34
|
|
|
multi_player_btn.pack(side="top", padx=10, pady=10) |
35
|
|
|
|
36
|
|
|
edit_config_btn = Button(self.frame, text="Settings", command=self.settings) |
37
|
|
|
edit_config_btn.pack(side="top", padx=10, pady=10) |
38
|
|
|
|
39
|
|
|
update_btn = Button(self.frame, text="Update", command=self.update_game) |
40
|
|
|
update_btn.pack(side="top", padx=10, pady=10) |
41
|
|
|
|
42
|
|
|
help_btn = Button(self.frame, text="Help", command=self.help) |
43
|
|
|
help_btn.pack(side="top", padx=10, pady=10) |
44
|
|
|
|
45
|
|
|
about_btn = Button(self.frame, text="About", command=self.about) |
46
|
|
|
about_btn.pack(side="top", padx=10, pady=10) |
47
|
|
|
|
48
|
|
|
exit_btn = Button(self.frame, text="Exit", command=quit) |
49
|
|
|
exit_btn.pack(side="top", padx=10, pady=10) |
50
|
|
|
|
51
|
|
|
def single_player(self): |
52
|
|
|
# todo show choose difficulty window |
53
|
|
|
self.game.single_player() |
54
|
|
|
|
55
|
|
|
def multi_player(self): |
56
|
|
|
# todo show choose difficulty window |
57
|
|
|
self.game.multi_player() |
58
|
|
|
|
59
|
|
|
def settings(self): |
60
|
|
|
print('settings button') |
61
|
|
|
|
62
|
|
|
def update_game(self): |
63
|
|
|
is_updatable = self.game.update_available() |
64
|
|
|
print(is_updatable) |
65
|
|
|
|
66
|
|
|
def help(self): |
67
|
|
|
print('help button') |
68
|
|
|
|
69
|
|
|
def about(self): |
70
|
|
|
print('about button') |
71
|
|
|
|
72
|
|
|
|
73
|
|
|
if __name__ == '__main__': |
74
|
|
|
gui = GUI() |
75
|
|
|
|