-
Notifications
You must be signed in to change notification settings - Fork 0
/
pk4adi_demo.py
50 lines (39 loc) · 1.26 KB
/
pk4adi_demo.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
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@File : demo.py
@Contact : Jiang Feng([email protected])
@License : (C)Copyright 2004-2020, Zhejiang University
"""
import os
import sys
from qfluentwidgets import FluentTranslator
from PyQt5.QtCore import Qt, QTranslator
from PyQt5.QtWidgets import QApplication
import globalvar.vars as gl
from common.config import cfg
from view.main_window import MainWindow
# enable dpi scale
if cfg.get(cfg.dpiScale) == "Auto":
QApplication.setHighDpiScaleFactorRoundingPolicy(
Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
else:
os.environ["QT_ENABLE_HIGHDPI_SCALING"] = "0"
os.environ["QT_SCALE_FACTOR"] = str(cfg.get(cfg.dpiScale))
QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
# create application
app = QApplication(sys.argv)
app.setAttribute(Qt.AA_DontCreateNativeWidgetSiblings)
# internationalization
locale = cfg.get(cfg.language).value
translator = FluentTranslator(locale)
galleryTranslator = QTranslator()
galleryTranslator.load(locale, "pk4adi_calculator", ".", "./resource/i18n")
app.installTranslator(translator)
app.installTranslator(galleryTranslator)
gl.init_()
# create main window
w = MainWindow()
w.show()
app.exec_()