Skip to content

Commit 9dd4ac9

Browse files
committed
fix run
1 parent 213d5cf commit 9dd4ac9

File tree

7 files changed

+53
-21
lines changed

7 files changed

+53
-21
lines changed

.settings/org.eclipse.core.resources.prefs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
eclipse.preferences.version=1
22
encoding//Resources/Data/Projects/PyQt/Demo/FacePoints.py=utf-8
3+
encoding//Resources/Data/Projects/PyQt/QWebView/GetCookie.py=utf-8
34
encoding//Test/BaseApplyStyle.py=utf-8
45
encoding//Test/CustomCursor.py=utf-8
56
encoding//Test/GenerateLanguage.py=utf-8

PyQtClient.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
@description:
1111
"""
1212

13+
from distutils.sysconfig import get_python_lib
1314
import os
1415
import sys
1516
import traceback
@@ -23,11 +24,19 @@
2324

2425
sys.path.append(os.path.abspath('Library.zip'))
2526

26-
# libpath = get_python_lib()
27-
# os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = os.path.join(
28-
# libpath, 'PyQt5', 'Qt', 'plugins', 'platforms')
29-
# os.environ['QML_IMPORT_PATH'] = os.path.join(libpath, 'Qt', 'qml')
30-
# os.environ['QML2_IMPORT_PATH'] = os.environ['QML_IMPORT_PATH']
27+
libpath = get_python_lib()
28+
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = os.path.join(
29+
libpath, 'PyQt5', 'Qt', 'plugins', 'platforms')
30+
os.environ['QML_IMPORT_PATH'] = os.path.join(libpath, 'Qt', 'qml')
31+
os.environ['QML2_IMPORT_PATH'] = os.environ['QML_IMPORT_PATH']
32+
33+
if os.name == 'nt':
34+
os.environ['PATH'] = os.path.join(
35+
libpath, 'PyQt5', 'Qt', 'bin') + os.pathsep + os.environ['PATH']
36+
os.environ['PATH'] = os.path.dirname(
37+
os.path.abspath(sys.argv[0])) + os.pathsep + os.environ['PATH']
38+
39+
print(os.environ['PATH'])
3140

3241

3342
def escape(s):
File renamed without changes.

Utils/ThemeManager.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,17 @@ def loadTheme(cls):
289289
except Exception as e:
290290
AppLog.exception(e)
291291

292+
@classmethod
293+
def loadFont(cls):
294+
"""加载字体
295+
"""
296+
ThemeManager.ThemeName = Setting.value('theme', 'Default', str)
297+
# 加载主题中的字体
298+
path = cls.fontPath()
299+
AppLog.info('fontPath: {}'.format(path))
300+
if os.path.isfile(path):
301+
QFontDatabase.addApplicationFont(path)
302+
292303
@classmethod
293304
def loadUserTheme(cls, theme='Default'):
294305
"""加载主题目录里的主题

Widgets/MainWindow.py

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
import sys
1616

1717
from PyQt5 import QtCore
18-
from PyQt5.QtCore import QEvent, Qt, QTimer, pyqtSlot, QUrl, QProcess
18+
from PyQt5.QtCore import QEvent, Qt, QTimer, pyqtSlot, QUrl, QProcess,\
19+
QProcessEnvironment, QLibraryInfo
1920
from PyQt5.QtGui import QEnterEvent, QIcon
2021

2122
from UiFiles.Ui_MainWindow import Ui_FormMainWindow
@@ -137,20 +138,24 @@ def _runFile(self, file):
137138
process.setProperty('file', file)
138139
process.readChannelFinished.connect(self.onReadChannelFinished)
139140

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)
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+
if os.name == 'nt':
150+
env.insert(
151+
'PATH', QLibraryInfo.location(
152+
QLibraryInfo.BinariesPath) + os.pathsep + env.value('PATH')
153+
)
154+
env.insert(
155+
'PATH', os.path.dirname(
156+
os.path.abspath(sys.argv[0])) + os.pathsep + env.value('PATH')
157+
)
158+
process.setProcessEnvironment(env)
154159

155160
if sys.executable.endswith('python.exe'):
156161
process.setWorkingDirectory(os.path.dirname(file))
@@ -226,6 +231,9 @@ def main():
226231
else:
227232
# for Qt 5.5
228233
os.putenv('QT_DEVICE_PIXEL_RATIO', 'auto')
234+
if os.name == 'nt':
235+
os.environ['PATH'] = QLibraryInfo.location(
236+
QLibraryInfo.BinariesPath) + os.pathsep + os.environ['PATH']
229237
os.makedirs(Constants.DirErrors, exist_ok=True)
230238
os.makedirs(Constants.DirProject, exist_ok=True)
231239
os.makedirs(os.path.dirname(Constants.UpgradeFile), exist_ok=True)

Widgets/MainWindowBase.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ def _initUi(self):
6464
AppLog.debug('colourful: %s', str(colourful))
6565
AppLog.debug('picture: %s', picture)
6666
if picture:
67+
ThemeManager.loadFont()
6768
ThemeManager.loadPictureTheme(picture)
6869
elif colourful:
70+
ThemeManager.loadFont()
6971
if isinstance(picture, QColor):
7072
ThemeManager.loadColourfulTheme(colourful)
7173
else:
@@ -96,7 +98,7 @@ def _initLanguage(self):
9698
if QLocale.system().language() in (QLocale.China, QLocale.Chinese, QLocale.Taiwan, QLocale.HongKong):
9799
# 加载中文
98100
translator = QTranslator(self)
99-
translator.load('translations/pyqtclient_zh_CN.qm')
101+
translator.load('Resources/pyqtclient_zh_CN.qm')
100102
QApplication.instance().installTranslator(translator)
101103

102104
def _initWebView(self):

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
requests
22
pygit2==0.27.2
33
PyQt5==5.10.1
4+
PyQtWebKit==5.10.1
45
PyQt3D==5.10.1
56
PyQtChart==5.10.1
67
PyQtDataVisualization==5.10.1

0 commit comments

Comments
 (0)