Tue, 01 Jun 2021 19:37:46 +0200
Ported the plug-in to PyQt6 for eric7.
(But it needs rework for recent Pyramid version.)
# -*- coding: utf-8 -*- # Copyright (c) 2012 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> # """ Module implementing a dialog for entering the create parameters. """ from PyQt6.QtCore import pyqtSlot, QProcess from PyQt6.QtWidgets import QDialog, QDialogButtonBox from EricWidgets import EricMessageBox from .Ui_CreateParametersDialog import Ui_CreateParametersDialog import Preferences class CreateParametersDialog(QDialog, Ui_CreateParametersDialog): """ Class implementing a dialog for entering the create parameters. """ def __init__(self, project, parent=None): """ Constructor @param project reference to the project object @type Project @param parent reference to the parent widget @type QWidget """ super().__init__(parent) self.setupUi(self) self.__okButton = self.buttonBox.button( QDialogButtonBox.StandardButton.Ok) self.__okButton.setEnabled(False) errMsg = "" proc = QProcess() args = [] args.append(project.getPyramidCommand("pcreate")) args.append("--list") proc.start(args[0], args[1:]) procStarted = proc.waitForStarted() if procStarted: finished = proc.waitForFinished(30000) if finished and proc.exitCode() == 0: output = str(proc.readAllStandardOutput(), Preferences.getSystem("IOEncoding"), 'replace') else: if not finished: errMsg = self.tr( "The pcreate command did not finish within 30s.") else: errMsg = self.tr("Could not start the pcreate executable.") if not errMsg: lines = output.splitlines() self.scaffoldCombo.addItem("") for line in sorted(lines[1:]): self.scaffoldCombo.addItem( self.__prepareScaffoldString(line)) self.scaffoldCombo.setCurrentIndex(0) else: EricMessageBox.critical( None, self.tr('Process Generation Error'), errMsg) msh = self.minimumSizeHint() self.resize(max(self.width(), msh.width()), msh.height()) @pyqtSlot(str) def on_nameEdit_textChanged(self, text): """ Private slot to handle changes of the site name. @param text text of the site entry @type str """ self.__updateUi() @pyqtSlot(str) def on_scaffoldCombo_currentTextChanged(self, text): """ Private slot to handle changes of the selected scaffold. @param text text of the combo box @type str """ self.__updateUi() def __updateUi(self): """ Private slot to update the dialog. """ self.__okButton.setEnabled( bool(self.scaffoldCombo.currentText()) and bool(self.nameEdit.text()) ) def __prepareScaffoldString(self, line): """ Private method to prepare a scaffold string for the combo box. @param line output line containing the scaffold name and some explanatory text @type str @return prepared scaffold text @rtype str """ parts = [part.strip() for part in line.split(":", 1)] return self.tr( "{0} ({1})", "scaffold name, explanatory text").format(*parts) def getData(self): """ Public method to get the data. @return tuple giving the scaffold, the project name, a flag indicating to overwrite existing files and a flag indicating to simulate the creation @rtype tuple of (str, str, bool, bool) """ return ( self.scaffoldCombo.currentText().split(":")[0], self.nameEdit.text(), self.overwriteCheckBox.isChecked(), self.simulateCheckBox.isChecked() )