Skip to content

Commit ca30109

Browse files
committed
python: Don't import pygame if not needed
- Make pygame an optional dependency - Avoid the pygame hello print on startup ``` pygame 2.6.1 (SDL 2.28.4, Python 3.13.0) Hello from the pygame community. https://www.pygame.org/contribute.html ``` Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent cce7898 commit ca30109

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

python/inputmodule/cli.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@
6262
RGB_COLORS,
6363
)
6464

65-
# Optional dependencies:
66-
# from PIL import Image
67-
# import PySimpleGUI as sg
68-
6965

7066
def main_cli():
7167
parser = argparse.ArgumentParser()

python/inputmodule/gui/__init__.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
Game,
1919
GameControlVal
2020
)
21-
from inputmodule.gui.pygames import snake, ledris
2221
from inputmodule.gui.ledmatrix import countdown, random_eq, clock
2322
from inputmodule.gui.gui_threading import stop_thread, is_dev_disconnected
2423
from inputmodule.inputmodule.ledmatrix import (
@@ -233,12 +232,14 @@ def run_gui(devices):
233232
root.mainloop()
234233

235234
def perform_action(devices, action):
236-
action_map = {
237-
"game_snake": snake.main_devices,
238-
"game_ledris": ledris.main_devices,
239-
}
240-
if action in action_map:
241-
threading.Thread(target=action_map[action], args=(devices,), daemon=True).start(),
235+
if action.startswith("game_"):
236+
from inputmodule.gui.pygames import snake, ledris
237+
action_map = {
238+
"game_snake": snake.main_devices,
239+
"game_ledris": ledris.main_devices,
240+
}
241+
if action in action_map:
242+
threading.Thread(target=action_map[action], args=(devices,), daemon=True).start(),
242243

243244
if action == "bootloader":
244245
disable_devices(devices)

0 commit comments

Comments
 (0)