aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-07-17 22:57:26 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2023-07-17 22:57:26 +0200
commit0fe22d25beaa91aeb714934506e175e5e35b7315 (patch)
treeafa33e482f19f7cc0cd67a68afce28cb931ab09f
parent89cf7c5c14becb6ebfc682932dadf1e5697b2675 (diff)
downloadquiz-0fe22d25beaa91aeb714934506e175e5e35b7315.tar.gz
quiz-0fe22d25beaa91aeb714934506e175e5e35b7315.zip
use os.startfile to shwo questions on windows
-rwxr-xr-xquiz.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/quiz.py b/quiz.py
index d6c6a21..0571a5d 100755
--- a/quiz.py
+++ b/quiz.py
@@ -17,6 +17,7 @@ import csv
from pathlib import Path
import random
import platform
+import os
import tomllib
import subprocess
import sys
@@ -28,12 +29,12 @@ WRONG_SOUND = Path(__file__).parent / 'Wrong.mp3'
CORRECT_SOUND = Path(__file__).parent / 'Correct.mp3'
if platform.system() != 'Windows':
- SHOW_QUESTION_CMD = 'xdg-open'
PLAY_SOUND_CMD = 'mpv'
else:
- SHOW_QUESTION_CMD = 'start'
PLAY_SOUND_CMD = 'vlc.exe --intf=dummy --dummy-quiet'
+SHOW_QUESTION_CMD = 'xdg-open'
+
def err(msg: str, status=1):
"""Print the error message to stderr and exit with status"""
@@ -146,10 +147,14 @@ def load_solutions(question_dirs: list[Path],
return solutions
-def show_question(question: Path) -> subprocess.Popen:
+def show_question(question: Path):
"""show the question in an external programm and return the process"""
+ if platform.system() != 'Windows':
+ os.startfile(question) # type: ignore # pylint: disable=no-member
+ return
+
cmd = SHOW_QUESTION_CMD.split() + [str(question)]
- return subprocess.Popen(cmd, shell=True)
+ subprocess.Popen(cmd)
def color_button(layout, text: str, color: str):