This repository has been archived by the owner on Dec 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
ntscQT.py
executable file
·81 lines (61 loc) · 2.03 KB
/
ntscQT.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import os
import sys
from pathlib import Path
import traceback
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtCore import QLibraryInfo
from PyQt5.QtCore import QFile, QTextStream
from PyQt5 import QtGui
import darkdetect
import colorama
import qdarktheme
from app import NtscApp
from app import logger
import traceback
from halo import Halo
os.environ["QT_QPA_PLATFORM_PLUGIN_PATH"] = QLibraryInfo.location(
QLibraryInfo.PluginsPath
)
def crash_handler(etype, value, tb):
logger.trace(value)
traceback.print_exception(etype, value, tb)
logger.error("Uncaught exception: {0}\n{1}".format(str(value), "\n".join(traceback.format_tb(tb))))
sys.exit(1)
def cls():
os.system('cls' if os.name=='nt' else 'clear')
# Install exception handler
sys.excepthook = crash_handler
def main():
translator = QtCore.QTranslator()
locale = QtCore.QLocale.system().name()
cls()
print("📼 ntscQT+")
#print(f"by RGM, based on JargeZ's "+'\x1B[3m'+"ntscQT"+'\x1B[0m')
#print("")
spinner = Halo(text='',color='white')
spinner.start()
# if run by pyinstaller executable, frozen attr will be true
if getattr(sys, 'frozen', False):
# _MEIPASS contain temp pyinstaller dir
base_dir = Path(sys._MEIPASS)
locale_file = str((base_dir / 'translate' / f'{locale}.qm').resolve())
else:
base_dir = Path(__file__).absolute().parent
locale_file = str((base_dir / 'translate' / f'{locale}.qm').resolve())
#print(f"Try load {locale} locale: {locale_file}")
app = QtWidgets.QApplication(sys.argv)
app.setWindowIcon(QtGui.QIcon(QtGui.QPixmap("./icon.png")))
app.installTranslator(translator)
qdarktheme.setup_theme("dark",corner_shape="sharp")
spinner.stop()
print("Loaded.")
if translator.load(locale_file):
print(f'Localization loaded: {locale}') # name, dir
else:
print("")
print("Using default translation")
window = NtscApp()
window.showMaximized()
sys.exit(app.exec_())
if __name__ == '__main__':
main()