Sun, 06 Jun 2021 16:30:37 +0200
Ported the plug-in to PyQt6 for eric7 and adopted it for Pyramid 2.x.
# -*- 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 from PyQt6.QtWidgets import QDialog, QDialogButtonBox from .Ui_CreateParametersDialog import Ui_CreateParametersDialog class CreateParametersDialog(QDialog, Ui_CreateParametersDialog): """ Class implementing a dialog for entering the create parameters. """ PyramidStarterGH = "gh:Pylons/pyramid-cookiecutter-starter" PyramidStarter = "pyramid-cookiecutter-starter" def __init__(self, parent=None): """ Constructor @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) self.templateCombo.addItems([ "", CreateParametersDialog.PyramidStarter, CreateParametersDialog.PyramidStarterGH, ]) self.templateLanguageCombo.addItem("Jinja2", "jinja") self.templateLanguageCombo.addItem("Chameleon", "chameleon") self.templateLanguageCombo.addItem("Mako", "mako") self.backendCombo.addItem(self.tr("No Database"), "none") self.backendCombo.addItem("SQLAlchemy", "sqlalchemy") self.backendCombo.addItem("ZODB", "zodb") self.starterGroupBox.setEnabled(False) msh = self.minimumSizeHint() self.resize(max(self.width(), msh.width()), msh.height()) @pyqtSlot(str) def on_templateCombo_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. """ template = self.templateCombo.currentText() self.__okButton.setEnabled(bool(template)) self.starterGroupBox.setEnabled( template in ( CreateParametersDialog.PyramidStarter, CreateParametersDialog.PyramidStarterGH, ) ) self.versionEdit.setEnabled( template == CreateParametersDialog.PyramidStarterGH) def getData(self): """ Public method to get the data. @return tuple giving the template name, an optional template version, a flag indicating to overwrite existing files and a dictionary containing additional context data @rtype tuple of (str, str, bool) """ template = self.templateCombo.currentText() contextData = ( { "project_name": self.projectEdit.text(), "repo_name": "_".join(self.projectEdit.text().split()).lower(), "template_language": self.templateLanguageCombo.currentData(), "backend": self.backendCombo.currentData(), } if template in ( CreateParametersDialog.PyramidStarter, CreateParametersDialog.PyramidStarterGH, ) else {} ) version = ( self.versionEdit.text() if template == CreateParametersDialog.PyramidStarterGH else "" ) return ( template, version, self.overwriteCheckBox.isChecked(), contextData )