Skip to content

Commit ddffb07

Browse files
committed
python: Add ledris in tkinter GUI
Signed-off-by: Daniel Schaefer <[email protected]>
1 parent c6e0ac6 commit ddffb07

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

Diff for: python/inputmodule/gui/__init__.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
CommandVals,
1515
)
1616
from inputmodule.gui.games import snake
17+
from inputmodule.gui.games import ledris
1718
from inputmodule.gui.ledmatrix import countdown, random_eq, clock
1819
from inputmodule.gui.gui_threading import stop_thread, is_dev_disconnected
1920
from inputmodule.inputmodule.ledmatrix import (
@@ -49,9 +50,11 @@ def run_gui(devices):
4950

5051
tabControl = ttk.Notebook(root)
5152
tab1 = ttk.Frame(tabControl)
53+
tab_games = ttk.Frame(tabControl)
5254
tab2 = ttk.Frame(tabControl)
5355
tab3 = ttk.Frame(tabControl)
5456
tabControl.add(tab1, text="Home")
57+
tabControl.add(tab_games, text="Games")
5558
tabControl.add(tab2, text="Dynamic Controls")
5659
tabControl.add(tab3, text="Advanced")
5760
tabControl.pack(expand=1, fill="both")
@@ -103,6 +106,11 @@ def run_gui(devices):
103106
percentage_scale = tk.Scale(percentage_frame, from_=0, to=100, orient='horizontal', command=lambda value: set_percentage(devices, value))
104107
percentage_scale.pack(fill="x", padx=5, pady=5)
105108

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+
106114
# Countdown Timer
107115
countdown_frame = ttk.LabelFrame(tab2, text="Countdown Timer", style="TLabelframe")
108116
countdown_frame.pack(fill="x", padx=10, pady=5)
@@ -160,18 +168,23 @@ def run_gui(devices):
160168
for text, action in control_buttons.items():
161169
ttk.Button(device_control_frame, text=text, command=lambda a=action: perform_action(devices, a), style="TButton").pack(side="left", padx=5, pady=5)
162170

163-
164171
root.mainloop()
165172

166173
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+
167180
action_map = {
168181
"bootloader": bootloader,
169182
"sleep": lambda dev: send_command(dev, CommandVals.Sleep, [True]),
170183
"wake": lambda dev: send_command(dev, CommandVals.Sleep, [False]),
171184
"start_animation": lambda dev: animate(dev, True),
172185
"stop_animation": lambda dev: animate(dev, False),
173186
"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(),
175188
}
176189
selected_devices = get_selected_devices(devices)
177190
for dev in selected_devices:
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)