|
15 | 15 | import sys |
16 | 16 |
|
17 | 17 | 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 |
19 | 20 | from PyQt5.QtGui import QEnterEvent, QIcon |
20 | 21 |
|
21 | 22 | from UiFiles.Ui_MainWindow import Ui_FormMainWindow |
@@ -137,20 +138,24 @@ def _runFile(self, file): |
137 | 138 | process.setProperty('file', file) |
138 | 139 | process.readChannelFinished.connect(self.onReadChannelFinished) |
139 | 140 |
|
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) |
154 | 159 |
|
155 | 160 | if sys.executable.endswith('python.exe'): |
156 | 161 | process.setWorkingDirectory(os.path.dirname(file)) |
@@ -226,6 +231,9 @@ def main(): |
226 | 231 | else: |
227 | 232 | # for Qt 5.5 |
228 | 233 | 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'] |
229 | 237 | os.makedirs(Constants.DirErrors, exist_ok=True) |
230 | 238 | os.makedirs(Constants.DirProject, exist_ok=True) |
231 | 239 | os.makedirs(os.path.dirname(Constants.UpgradeFile), exist_ok=True) |
|
0 commit comments