|
14 | 14 | CommandVals,
|
15 | 15 | )
|
16 | 16 | from inputmodule.gui.games import snake
|
| 17 | +from inputmodule.gui.games import ledris |
17 | 18 | from inputmodule.gui.ledmatrix import countdown, random_eq, clock
|
18 | 19 | from inputmodule.gui.gui_threading import stop_thread, is_dev_disconnected
|
19 | 20 | from inputmodule.inputmodule.ledmatrix import (
|
@@ -49,9 +50,11 @@ def run_gui(devices):
|
49 | 50 |
|
50 | 51 | tabControl = ttk.Notebook(root)
|
51 | 52 | tab1 = ttk.Frame(tabControl)
|
| 53 | + tab_games = ttk.Frame(tabControl) |
52 | 54 | tab2 = ttk.Frame(tabControl)
|
53 | 55 | tab3 = ttk.Frame(tabControl)
|
54 | 56 | tabControl.add(tab1, text="Home")
|
| 57 | + tabControl.add(tab_games, text="Games") |
55 | 58 | tabControl.add(tab2, text="Dynamic Controls")
|
56 | 59 | tabControl.add(tab3, text="Advanced")
|
57 | 60 | tabControl.pack(expand=1, fill="both")
|
@@ -103,6 +106,11 @@ def run_gui(devices):
|
103 | 106 | percentage_scale = tk.Scale(percentage_frame, from_=0, to=100, orient='horizontal', command=lambda value: set_percentage(devices, value))
|
104 | 107 | percentage_scale.pack(fill="x", padx=5, pady=5)
|
105 | 108 |
|
| 109 | + # Games tab |
| 110 | + games_frame = ttk.LabelFrame(tab_games, text="Games", style="TLabelframe") |
| 111 | + games_frame.pack(fill="x", padx=10, pady=5) |
| 112 | + ttk.Button(games_frame, text="Ledris", command=lambda: perform_action(devices, 'game_ledris'), style="TButton").pack(side="left", padx=5, pady=5) |
| 113 | + |
106 | 114 | # Countdown Timer
|
107 | 115 | countdown_frame = ttk.LabelFrame(tab2, text="Countdown Timer", style="TLabelframe")
|
108 | 116 | countdown_frame.pack(fill="x", padx=10, pady=5)
|
@@ -160,18 +168,23 @@ def run_gui(devices):
|
160 | 168 | for text, action in control_buttons.items():
|
161 | 169 | ttk.Button(device_control_frame, text=text, command=lambda a=action: perform_action(devices, a), style="TButton").pack(side="left", padx=5, pady=5)
|
162 | 170 |
|
163 |
| - |
164 | 171 | root.mainloop()
|
165 | 172 |
|
166 | 173 | def perform_action(devices, action):
|
| 174 | + action_map = { |
| 175 | + "game_ledris": ledris.main_devices |
| 176 | + } |
| 177 | + if action in action_map: |
| 178 | + threading.Thread(target=action_map[action], args=(devices,), daemon=True).start(), |
| 179 | + |
167 | 180 | action_map = {
|
168 | 181 | "bootloader": bootloader,
|
169 | 182 | "sleep": lambda dev: send_command(dev, CommandVals.Sleep, [True]),
|
170 | 183 | "wake": lambda dev: send_command(dev, CommandVals.Sleep, [False]),
|
171 | 184 | "start_animation": lambda dev: animate(dev, True),
|
172 | 185 | "stop_animation": lambda dev: animate(dev, False),
|
173 | 186 | "start_time": lambda dev: threading.Thread(target=clock, args=(dev,), daemon=True).start(),
|
174 |
| - "start_eq": lambda dev: threading.Thread(target=random_eq, args=(dev,), daemon=True).start() |
| 187 | + "start_eq": lambda dev: threading.Thread(target=random_eq, args=(dev,), daemon=True).start(), |
175 | 188 | }
|
176 | 189 | selected_devices = get_selected_devices(devices)
|
177 | 190 | for dev in selected_devices:
|
|
0 commit comments