-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.py
50 lines (42 loc) · 1.33 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from os import path
import platform
import sys
from PySide6.QtWidgets import QApplication
from PySide6.QtCore import (
QTranslator,
QLocale,
)
from mainwindow import MainWindow
from sc_logging import logger
from http_server import stop_http_server
if __name__ == "__main__":
# only attempt splash when not on Mac OSX
os_name = platform.system()
if os_name != "Darwin":
try:
import pyi_splash # type: ignore
pyi_splash.close()
except ImportError:
pass
app = QApplication(sys.argv)
# Get system locale
locale = QLocale.system().name()
# Load the translation file based on the locale
translator = QTranslator()
locale_file = path.abspath(
path.join(path.dirname(__file__), "translations", f"scoresight_{locale}.qm")
)
# check if the file exists
if not path.exists(locale_file):
# load the default translation file
locale_file = path.abspath(
path.join(path.dirname(__file__), "translations", "scoresight_en_US.qm")
)
if translator.load(locale_file):
app.installTranslator(translator)
# show the main window
mainWindow = MainWindow(translator, app)
mainWindow.show()
app.exec()
logger.info("Exiting...")
stop_http_server()