更多组件支持设置字体大小

This commit is contained in:
2023-08-13 21:50:29 +08:00
parent ef8c115df2
commit cb0cd776a4
8 changed files with 132 additions and 36 deletions

View File

@@ -0,0 +1,53 @@
#!/usr/bin/env python3
# 读取设置单独用一个 py 文件
import os
import json
import PyQt5.QtGui as QtGui
# 获取用户主目录
def get_home():
return os.path.expanduser('~')
# 读取文本文档
def readtxt(path):
f = open(path, "r") # 设置文件对象
str = f.read() # 获取内容
f.close() # 关闭文本对象
return str # 返回结果
defultProgramList = {
"Architecture": "Auto",
"Debug": True,
"DefultWine": "deepin-wine6 stable",
"DefultBotton" : get_home() + "/.wine",
"TerminalOpen": False,
"WineOption": "",
"WineBottonDifferent": False,
"CenterWindow": False,
"Theme": "",
"MonoGeckoInstaller": False,
"AutoWine": True,
"RuntimeCache": True,
"MustRead": False,
"BuildByBottleName": False,
"AutoPath": False,
"QemuUnMountHome": False,
"Chinese": True,
"FontSize": 1
}
def SetFont(app):
defaultFont = app.font()
size = setting["FontSize"]
font = QtGui.QFont(defaultFont)
if size == 1:
app.setFont(defaultFont)
return
font.setPixelSize(int(defaultFont.pixelSize() / size))
font.setPointSize(int(defaultFont.pointSize() / size))
app.setFont(font)
try:
setting = json.loads(readtxt(get_home() + "/.config/deepin-wine-runner/WineSetting.json"))
except:
setting = defultProgramList

View File

@@ -20,6 +20,7 @@ import PyQt5.QtGui as QtGui
import PyQt5.QtCore as QtCore
import PyQt5.QtWidgets as QtWidgets
from trans import *
from DefaultSetting import *
###################
# 程序所需事件
@@ -286,4 +287,6 @@ windowFrameInputValueList = [
packageName,
versionName
]
# 设置字体
SetFont(app)
sys.exit(app.exec_())