diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2024-05-16 10:43:27 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2024-05-16 10:43:27 +0200 |
| commit | ed390d98dde6bbc8997de8aca6d0233fe529a758 (patch) | |
| tree | 301e312f869710ef5ad2b7e9e3534afd8738fa97 /quiz.py | |
| parent | 9ff277c02aa8369066f7d3380508b7e0dd67036a (diff) | |
| download | quiz-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-x | quiz.py | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -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() |
