eric6/Project/CreateDialogCodeDialog.py

branch
maintenance
changeset 8043
0acf98cd089a
parent 7924
8a96736d465e
parent 7923
91e843545d9a
child 8176
31965986ecd1
equal deleted inserted replaced
7991:866adc8c315b 8043:0acf98cd089a
24 24
25 from .Ui_CreateDialogCodeDialog import Ui_CreateDialogCodeDialog 25 from .Ui_CreateDialogCodeDialog import Ui_CreateDialogCodeDialog
26 from .NewDialogClassDialog import NewDialogClassDialog 26 from .NewDialogClassDialog import NewDialogClassDialog
27 27
28 from eric6config import getConfig 28 from eric6config import getConfig
29
30 import Preferences
29 31
30 32
31 pyqtSignatureRole = Qt.UserRole + 1 33 pyqtSignatureRole = Qt.UserRole + 1
32 pythonSignatureRole = Qt.UserRole + 2 34 pythonSignatureRole = Qt.UserRole + 2
33 rubySignatureRole = Qt.UserRole + 3 35 rubySignatureRole = Qt.UserRole + 3
157 @param command uic command to be run 159 @param command uic command to be run
158 @type str 160 @type str
159 @return tuple of process output and error flag 161 @return tuple of process output and error flag
160 @rtype tuple of (str, bool) 162 @rtype tuple of (str, bool)
161 """ 163 """
164 venvManager = e5App().getObject("VirtualEnvManager")
165 projectType = self.project.getProjectType()
166
162 venvName = self.project.getDebugProperty("VIRTUALENV") 167 venvName = self.project.getDebugProperty("VIRTUALENV")
163 venvManager = e5App().getObject("VirtualEnvManager") 168 if not venvName:
169 # no project specific environment, try a type specific one
170 if projectType in ("PyQt5", "E6Plugin", "PySide2"):
171 venvName = Preferences.getQt("PyQtVenvName")
172 elif projectType in ("PyQt6", "PySide6"):
173 venvName = Preferences.getQt("PyQt6VenvName")
164 interpreter = venvManager.getVirtualenvInterpreter(venvName) 174 interpreter = venvManager.getVirtualenvInterpreter(venvName)
165 execPath = venvManager.getVirtualenvExecPath(venvName) 175 execPath = venvManager.getVirtualenvExecPath(venvName)
166 176
167 if not interpreter: 177 if not interpreter:
168 interpreter = sys.executable 178 interpreter = sys.executable
174 "PATH", os.pathsep.join([execPath, env.value("PATH")]) 184 "PATH", os.pathsep.join([execPath, env.value("PATH")])
175 ) 185 )
176 else: 186 else:
177 env.insert("PATH", execPath) 187 env.insert("PATH", execPath)
178 188
179 loadUi = os.path.join(os.path.dirname(__file__), "UicLoadUi.py") 189 if projectType in ("PyQt5", "E6Plugin", "PySide2"):
190 loadUi = os.path.join(os.path.dirname(__file__), "UicLoadUi5.py")
191 elif projectType in ("PyQt6", "PySide6"):
192 loadUi = os.path.join(os.path.dirname(__file__), "UicLoadUi6.py")
180 args = [ 193 args = [
181 loadUi, 194 loadUi,
182 command, 195 command,
183 self.formFile, 196 self.formFile,
184 self.packagesPath, 197 self.packagesPath,
405 try: 418 try:
406 if self.project.getProjectType() == "PySide2": 419 if self.project.getProjectType() == "PySide2":
407 tmplName = os.path.join( 420 tmplName = os.path.join(
408 getConfig('ericCodeTemplatesDir'), 421 getConfig('ericCodeTemplatesDir'),
409 "impl_pyside2.py.tmpl") 422 "impl_pyside2.py.tmpl")
423 elif self.project.getProjectType() == "PySide6":
424 tmplName = os.path.join(
425 getConfig('ericCodeTemplatesDir'),
426 "impl_pyside6.py.tmpl")
410 elif self.project.getProjectType() in [ 427 elif self.project.getProjectType() in [
411 "PyQt5", "E6Plugin"]: 428 "PyQt5", "E6Plugin"]:
412 tmplName = os.path.join( 429 tmplName = os.path.join(
413 getConfig('ericCodeTemplatesDir'), 430 getConfig('ericCodeTemplatesDir'),
414 "impl_pyqt5.py.tmpl") 431 "impl_pyqt5.py.tmpl")
432 elif self.project.getProjectType() == "PyQt6":
433 tmplName = os.path.join(
434 getConfig('ericCodeTemplatesDir'),
435 "impl_pyqt6.py.tmpl")
415 else: 436 else:
416 E5MessageBox.critical( 437 E5MessageBox.critical(
417 self, 438 self,
418 self.tr("Code Generation"), 439 self.tr("Code Generation"),
419 self.tr( 440 self.tr(
487 if line.lstrip().startswith("def __init__"): 508 if line.lstrip().startswith("def __init__"):
488 indentStr = line.replace(line.lstrip(), "") 509 indentStr = line.replace(line.lstrip(), "")
489 break 510 break
490 511
491 # do the coding stuff 512 # do the coding stuff
492 if self.project.getProjectType() in ("PySide2",): 513 if self.project.getProjectType() in ("PySide2", "PySide6"):
493 pyqtSignatureFormat = '@Slot({0})' 514 pyqtSignatureFormat = '@Slot({0})'
494 else: 515 else:
495 pyqtSignatureFormat = '@pyqtSlot({0})' 516 pyqtSignatureFormat = '@pyqtSlot({0})'
496 for row in range(self.slotsModel.rowCount()): 517 for row in range(self.slotsModel.rowCount()):
497 topItem = self.slotsModel.item(row) 518 topItem = self.slotsModel.item(row)

eric ide

mercurial