Skip to content

Commit 213d5cf

Browse files
committed
SCALE
1 parent 6937144 commit 213d5cf

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

Widgets/MainWindow.py

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from random import randint
1515
import sys
1616

17+
from PyQt5 import QtCore
1718
from PyQt5.QtCore import QEvent, Qt, QTimer, pyqtSlot, QUrl, QProcess
1819
from PyQt5.QtGui import QEnterEvent, QIcon
1920

@@ -136,17 +137,20 @@ def _runFile(self, file):
136137
process.setProperty('file', file)
137138
process.readChannelFinished.connect(self.onReadChannelFinished)
138139

139-
# env = QProcessEnvironment.systemEnvironment()
140-
# libpath = get_python_lib()
141-
# env.insert('QT_QPA_PLATFORM_PLUGIN_PATH', os.path.join(
142-
# libpath, 'PyQt5', 'Qt', 'plugins', 'platforms'))
143-
# env.insert('QML_IMPORT_PATH', os.path.join(libpath, 'Qt', 'qml'))
144-
# env.insert('QML2_IMPORT_PATH', env.value('QML_IMPORT_PATH'))
145-
# env.insert(
146-
# 'PATH', QLibraryInfo.location(
147-
# QLibraryInfo.BinariesPath) + ';' + env.value('PATH')
148-
# )
149-
# process.setProcessEnvironment(env)
140+
# if os.path.exists('platforms'):
141+
# env = QProcessEnvironment.systemEnvironment()
142+
# # libpath = get_python_lib()
143+
# # env.insert('QT_QPA_PLATFORM_PLUGIN_PATH', os.path.join(
144+
# # libpath, 'PyQt5', 'Qt', 'plugins', 'platforms'))
145+
# env.insert('QT_QPA_PLATFORM_PLUGIN_PATH',
146+
# os.path.abspath('platforms'))
147+
# env.insert('QML_IMPORT_PATH', os.path.abspath('qml'))
148+
# env.insert('QML2_IMPORT_PATH', env.value('QML_IMPORT_PATH'))
149+
# env.insert(
150+
# 'PATH', QLibraryInfo.location(
151+
# QLibraryInfo.BinariesPath) + ';' + env.value('PATH')
152+
# )
153+
# process.setProcessEnvironment(env)
150154

151155
if sys.executable.endswith('python.exe'):
152156
process.setWorkingDirectory(os.path.dirname(file))
@@ -160,7 +164,12 @@ def _runJs(self, code):
160164

161165
def onReadChannelFinished(self):
162166
process = self.sender()
163-
message = process.readAllStandardError().data().decode()
167+
message = process.readAllStandardError().data()
168+
try:
169+
message = message.decode(errors='ignore')
170+
except Exception as e:
171+
AppLog.exception(e)
172+
return
164173
if process.exitCode() != 0 and len(message.strip()) > 0:
165174
file = str(process.property('file'))
166175
reqfile = os.path.abspath(os.path.join(
@@ -211,10 +220,12 @@ def changeEvent(self, event):
211220

212221

213222
def main():
214-
# for Qt 5.5
215-
os.putenv('QT_DEVICE_PIXEL_RATIO', 'auto')
216-
# for > Qt 5.5
217-
os.putenv('QT_AUTO_SCREEN_SCALE_FACTOR', '1')
223+
if int(QtCore.PYQT_VERSION_STR.split('.')[1]) > 5:
224+
# for > Qt 5.5
225+
os.putenv('QT_AUTO_SCREEN_SCALE_FACTOR', '1')
226+
else:
227+
# for Qt 5.5
228+
os.putenv('QT_DEVICE_PIXEL_RATIO', 'auto')
218229
os.makedirs(Constants.DirErrors, exist_ok=True)
219230
os.makedirs(Constants.DirProject, exist_ok=True)
220231
os.makedirs(os.path.dirname(Constants.UpgradeFile), exist_ok=True)

0 commit comments

Comments
 (0)