-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
45 lines (36 loc) · 1.15 KB
/
Copy pathmain.py
File metadata and controls
45 lines (36 loc) · 1.15 KB
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
# coding: utf-8
import os
import sys
import ctypes
from pathlib import Path
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QApplication
from qfluentwidgets import FluentTranslator
from app.common.config import cfg
if cfg.get(cfg.dpiScale) != "Auto":
os.environ["QT_ENABLE_HIGHDPI_SCALING"] = "0"
os.environ["QT_SCALE_FACTOR"] = str(cfg.get(cfg.dpiScale))
else:
QApplication.setHighDpiScaleFactorRoundingPolicy(
Qt.HighDpiScaleFactorRoundingPolicy.PassThrough
)
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
app = QApplication(sys.argv)
app.setAttribute(Qt.AA_DontCreateNativeWidgetSiblings)
locale = cfg.get(cfg.language).value
translator = FluentTranslator(locale)
app.installTranslator(translator)
from app.view.main_window import MainWindow # noqa: E402
w = MainWindow()
if sys.platform == "win32":
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(
"pyqt.ui.designer"
)
_icon_path = Path(__file__).resolve().parent / "logo.ico"
if _icon_path.exists():
_icon = QIcon(str(_icon_path))
app.setWindowIcon(_icon)
w.setWindowIcon(_icon)
w.show()
app.exec()