diff -r c31a4f756a04 -r 22e1d0f69668 ProjectFlask/FlaskVirtualenvConfigurationDialog.py --- a/ProjectFlask/FlaskVirtualenvConfigurationDialog.py Thu Dec 30 12:13:22 2021 +0100 +++ b/ProjectFlask/FlaskVirtualenvConfigurationDialog.py Wed Sep 21 16:30:15 2022 +0200 @@ -16,9 +16,7 @@ from EricWidgets.EricPathPicker import EricPathPickerModes -from .Ui_FlaskVirtualenvConfigurationDialog import ( - Ui_FlaskVirtualenvConfigurationDialog -) +from .Ui_FlaskVirtualenvConfigurationDialog import Ui_FlaskVirtualenvConfigurationDialog import Utilities @@ -29,14 +27,15 @@ """ Class implementing a dialog to configure a project specific virtual environment. - + Note: This dialog is a simplified variant of the one found in the eric package. """ + def __init__(self, projectPath, projectName, parent=None): """ Constructor - + @param projectPath directory path of the project @type str @param projectName name of the project @@ -46,79 +45,79 @@ """ super().__init__(parent) self.setupUi(self) - + self.targetDirectoryPicker.setMode(EricPathPickerModes.DIRECTORY_MODE) self.targetDirectoryPicker.setWindowTitle( - self.tr("Virtualenv Target Directory")) + self.tr("Virtualenv Target Directory") + ) self.targetDirectoryPicker.setDefaultDirectory(projectPath) - + self.pythonExecPicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) - self.pythonExecPicker.setWindowTitle( - self.tr("Python Interpreter")) + self.pythonExecPicker.setWindowTitle(self.tr("Python Interpreter")) self.pythonExecPicker.setDefaultDirectory( - sys.executable.replace("w.exe", ".exe")) - + sys.executable.replace("w.exe", ".exe") + ) + mandatoryStyleSheet = "QLineEdit {border: 2px solid;}" self.targetDirectoryPicker.setStyleSheet(mandatoryStyleSheet) self.nameEdit.setStyleSheet(mandatoryStyleSheet) - + # pre-populate some fields self.nameEdit.setText("Project {0}".format(projectName)) self.targetDirectoryPicker.setText(os.path.join(projectPath, "venv")) - + msh = self.minimumSizeHint() self.resize(max(self.width(), msh.width()), msh.height()) - + def __updateOK(self): """ Private method to update the enabled status of the OK button. """ self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( - bool(self.targetDirectoryPicker.text()) and - bool(self.nameEdit.text()) + bool(self.targetDirectoryPicker.text()) and bool(self.nameEdit.text()) ) - + @pyqtSlot(str) def on_nameEdit_textChanged(self, txt): """ Private slot handling a change of the virtual environment name. - + @param txt name of the virtual environment @type str """ self.__updateOK() - + @pyqtSlot(str) def on_targetDirectoryPicker_textChanged(self, txt): """ Private slot handling a change of the target directory. - + @param txt target directory @type str """ self.__updateOK() - + def __generateTargetDir(self): """ Private method to generate a valid target directory path. - + @return target directory path @rtype str """ targetDirectory = Utilities.toNativeSeparators( - self.targetDirectoryPicker.text()) + self.targetDirectoryPicker.text() + ) if not os.path.isabs(targetDirectory): - targetDirectory = os.path.join(os.path.expanduser("~"), - targetDirectory) + targetDirectory = os.path.join(os.path.expanduser("~"), targetDirectory) return targetDirectory - + def getData(self): """ Public method to retrieve the dialog data. - + Note: This method returns a data structure compatible with the one returned by the eric virtual environment configuration dialog. - + @return dictionary containing the data for the environment to be created. The keys for both variants are 'arguments' containing the command line arguments, 'logicalName' containing the environment @@ -140,8 +139,7 @@ "createLog": False, "createScript": False, "targetDirectory": self.__generateTargetDir(), - "pythonExe": Utilities.toNativeSeparators( - self.pythonExecPicker.text()), + "pythonExe": Utilities.toNativeSeparators(self.pythonExecPicker.text()), } - + return resultDict