-
Notifications
You must be signed in to change notification settings - Fork 1
/
main_gui.py
64 lines (44 loc) · 1.58 KB
/
main_gui.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
import logging.config
import os
import sys
from multiprocessing import freeze_support
import colorama
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
import core.utils
import gui
from core.constants import APP_NAME
from core.constants import IS_FROZEN, VERSION
from gui.constants import ASSETS_PATH, TUTORIAL_URL
from settings.logger import setup_logger
try:
from PyQt5.QtWinExtras import QtWin
app_id = f"{APP_NAME}.{APP_NAME}"
QtWin.setCurrentProcessExplicitAppUserModelID(app_id)
except ImportError:
pass
logger = logging.getLogger(__name__)
def default_sys_except_hook(cls, exception, traceback):
sys.__excepthook__(cls, exception, traceback)
def log_and_exit_except_hook(cls, exception, traceback):
logger.critical("Unhandled Exception", exc_info=exception)
sys.exit(1)
if __name__ == "__main__":
freeze_support()
colorama.init()
if IS_FROZEN:
sys.excepthook = log_and_exit_except_hook
else:
sys.excepthook = default_sys_except_hook
QGuiApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.RoundPreferFloor)
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
app = gui.Application(sys.argv)
setup_logger(app.behavior_settings.loglevel)
logger.debug(f"Current Version: {VERSION}")
logger.debug(f"AppData Path: {core.utils.get_app_data_path()}")
app.set_current_setting_theme()
app.setWindowIcon(QIcon(os.path.join(ASSETS_PATH, "logo", "logo.ico")))
main_window = gui.MainWindow()
main_window.show()
sys.exit(app.exec_())