aboutsummaryrefslogtreecommitdiff
path: root/quiz.py
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2024-05-16 10:43:27 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2024-05-16 10:43:27 +0200
commited390d98dde6bbc8997de8aca6d0233fe529a758 (patch)
tree301e312f869710ef5ad2b7e9e3534afd8738fa97 /quiz.py
parent9ff277c02aa8369066f7d3380508b7e0dd67036a (diff)
downloadquiz-ed390d98dde6bbc8997de8aca6d0233fe529a758.tar.gz
quiz-ed390d98dde6bbc8997de8aca6d0233fe529a758.zip
update dependencies and make playsound optional
Since pysimplegui changed to a subscription model with 5.* we pin our used version to the last non purged on on pypi.
Diffstat (limited to 'quiz.py')
-rwxr-xr-xquiz.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/quiz.py b/quiz.py
index d6f58bd..d4f4658 100755
--- a/quiz.py
+++ b/quiz.py
@@ -22,10 +22,17 @@ import os
import tomllib
import subprocess
import sys
+import importlib
+
import PySimpleGUI as sg
import psutil
-import playsound
+
+playsound = None
+try:
+ playsound = importlib.import_module('playsound')
+except ModuleNotFoundError:
+ pass
WRONG_SOUND = Path(__file__).parent / 'Wrong.mp3'
CORRECT_SOUND = Path(__file__).parent / 'Correct.mp3'
@@ -186,10 +193,12 @@ def prompt_solution(solution: str, prompts=None):
break
color_button(layout[0], event, '#FF0000')
- playsound.playsound(WRONG_SOUND)
+ if playsound:
+ playsound.playsound(WRONG_SOUND)
color_button(layout[0], event, '#00FF00')
- playsound.playsound(CORRECT_SOUND)
+ if playsound:
+ playsound.playsound(CORRECT_SOUND)
window.read()
window.close()