diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-07-17 22:57:26 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2023-07-17 22:57:26 +0200 |
| commit | 0fe22d25beaa91aeb714934506e175e5e35b7315 (patch) | |
| tree | afa33e482f19f7cc0cd67a68afce28cb931ab09f | |
| parent | 89cf7c5c14becb6ebfc682932dadf1e5697b2675 (diff) | |
| download | quiz-0fe22d25beaa91aeb714934506e175e5e35b7315.tar.gz quiz-0fe22d25beaa91aeb714934506e175e5e35b7315.zip | |
use os.startfile to shwo questions on windows
| -rwxr-xr-x | quiz.py | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -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): |
