diff -r e9e7eca7efee -r bf71ee032bb4 src/eric7/EricWidgets/EricPathPickerDialog.py --- a/src/eric7/EricWidgets/EricPathPickerDialog.py Wed Jul 13 11:16:20 2022 +0200 +++ b/src/eric7/EricWidgets/EricPathPickerDialog.py Wed Jul 13 14:55:47 2022 +0200 @@ -17,106 +17,115 @@ Class implementing a dialog to enter a file system path using a file picker. """ + def __init__(self, parent=None): """ Constructor - + @param parent reference to the parent widget @type QWidget """ super().__init__(parent) - + self.setMinimumWidth(400) - + self.__layout = QVBoxLayout(self) - + self.__label = QLabel(self) self.__label.setWordWrap(True) - + self.__pathPicker = EricPathPicker(self) self.__buttonBox = QDialogButtonBox( - QDialogButtonBox.StandardButton.Cancel | - QDialogButtonBox.StandardButton.Ok, self) - + QDialogButtonBox.StandardButton.Cancel | QDialogButtonBox.StandardButton.Ok, + self, + ) + self.__layout.addWidget(self.__label) self.__layout.addWidget(self.__pathPicker) self.__layout.addWidget(self.__buttonBox) - + self.__buttonBox.accepted.connect(self.accept) self.__buttonBox.rejected.connect(self.reject) - + def setLabelText(self, text): """ Public method to set the label text. - + @param text label text @type str """ self.__label.setText(text) - + def setTitle(self, title): """ Public method to set the window title. - + @param title window title @type str """ self.setWindowTitle(title) self.__pathPicker.setWindowTitle(title) - + def setPickerMode(self, mode): """ Public method to set the mode of the path picker. - + @param mode picker mode @type EricPathPickerModes """ self.__pathPicker.setMode(mode) - + def setPickerPath(self, path): """ Public method to set the path of the path picker. - + @param path path to be set @type str """ self.__pathPicker.setPath(path) - + def setDefaultDirectory(self, directory): """ Public method to set the default directory of the path picker. - + @param directory default directory @type str """ self.__pathPicker.setDefaultDirectory(directory) - + def setPickerFilters(self, filters): """ Public method to set the filters of the path picker. - + Note: Multiple filters must be separated by ';;'. - + @param filters string containing the file filters @type str """ self.__pathPicker.setFilters(filters) - + def getPath(self): """ Public method to get the current path. - + @return current path @rtype str """ return self.__pathPicker.path() -def getPath(parent, title, label, mode=EricPathPickerModes.OPEN_FILE_MODE, - path="", defaultDirectory="", filters=None): +def getPath( + parent, + title, + label, + mode=EricPathPickerModes.OPEN_FILE_MODE, + path="", + defaultDirectory="", + filters=None, +): """ Function to get a file or directory path from the user. - + @param parent reference to the parent widget @type QWidget @param title title of the dialog @@ -149,7 +158,7 @@ dlg.setDefaultDirectory(defaultDirectory) if filters is not None and len(filters) > 0: dlg.setPickerFilters(";;".join(filters)) - + # step 2: show the dialog and get the result if dlg.exec() == QDialog.DialogCode.Accepted: ok = True @@ -157,6 +166,6 @@ else: ok = False path = "" - + # step 3: return the result return path, ok