diff -r e9e7eca7efee -r bf71ee032bb4 src/eric7/Plugins/WizardPlugins/SetupWizard/AddEntryPointDialog.py --- a/src/eric7/Plugins/WizardPlugins/SetupWizard/AddEntryPointDialog.py Wed Jul 13 11:16:20 2022 +0200 +++ b/src/eric7/Plugins/WizardPlugins/SetupWizard/AddEntryPointDialog.py Wed Jul 13 14:55:47 2022 +0200 @@ -23,10 +23,11 @@ """ Class implementing a dialog to enter the data for an entry point. """ + def __init__(self, rootDirectory, epType="", name="", script="", parent=None): """ Constructor - + @param rootDirectory root directory for selecting script modules via a file selection dialog @type str @@ -41,42 +42,42 @@ """ super().__init__(parent) self.setupUi(self) - + for typeStr, category in ( ("", ""), (self.tr("Console"), "console_scripts"), (self.tr("GUI"), "gui_scripts"), ): self.typeComboBox.addItem(typeStr, category) - + self.scriptButton.setIcon(UI.PixmapCache.getIcon("open")) - + self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False) - + self.__rootDirectory = rootDirectory - + self.typeComboBox.currentTextChanged.connect(self.__updateOK) self.nameEdit.textChanged.connect(self.__updateOK) self.scriptEdit.textChanged.connect(self.__updateOK) - + self.typeComboBox.setCurrentText(epType) self.nameEdit.setText(name) self.scriptEdit.setText(script) - + msh = self.minimumSizeHint() self.resize(max(self.width(), msh.width()), msh.height()) - + @pyqtSlot() def __updateOK(self): """ Private slot to update the enabled state of the OK button. """ self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( - bool(self.typeComboBox.currentText()) and - bool(self.nameEdit.text()) and - bool(self.scriptEdit.text()) + bool(self.typeComboBox.currentText()) + and bool(self.nameEdit.text()) + and bool(self.scriptEdit.text()) ) - + @pyqtSlot() def on_scriptButton_clicked(self): """ @@ -93,31 +94,33 @@ else: root = self.__rootDirectory scriptFunction = "main" - + script = EricFileDialog.getOpenFileName( self, self.tr("Select Script File"), root, - self.tr("Python Files (*.py);;All Files (*)") + self.tr("Python Files (*.py);;All Files (*)"), ) - + if script: scriptPath = pathlib.Path(script) try: relativeScriptPath = scriptPath.relative_to(self.__rootDirectory) except ValueError: relativeScriptPath = scriptPath - self.scriptEdit.setText("{0}:{1}".format( - str(relativeScriptPath.with_suffix("")) - .replace("/", ".") - .replace("\\", "."), - scriptFunction - )) - + self.scriptEdit.setText( + "{0}:{1}".format( + str(relativeScriptPath.with_suffix("")) + .replace("/", ".") + .replace("\\", "."), + scriptFunction, + ) + ) + def getEntryPoint(self): """ Public method to get the data for the entry point. - + @return tuple containing the entry point type, category, name and script function @rtype tuple of (str, str, str)