def getOpenFileNamesAndFilter(parent=None, caption="", directory="", filter="", initialFilter="", options=QFileDialog.Options()): """ Module function to get a list of names of files for opening and the selected file name filter. @param parent parent widget of the dialog (QWidget) @param caption window title of the dialog (string) @param directory working directory of the dialog (string) @param filter filter string for the dialog (string) @param initialFilter initial filter for the dialog (string) @param options various options for the dialog (QFileDialog.Options) @return list of file names to be opened and selected filter (list of string, string) """ if Globals.isLinuxPlatform(): options |= QFileDialog.DontUseNativeDialog newfilter = __reorderFilter(filter, initialFilter) if PYQT_VERSION_STR >= "5.0.0": return QFileDialog.getOpenFileNames( parent, caption, directory, newfilter, initialFilter, options) else: return QFileDialog.getOpenFileNamesAndFilter( parent, caption, directory, newfilter, initialFilter, options)
def on_bTest_clicked(self): """ Private method to test the selected options. """ if self.rOpenFile.isChecked() or self.rfOpenFile.isChecked(): if not self.cSymlinks.isChecked(): options = QFileDialog.Options(QFileDialog.DontResolveSymlinks) else: options = QFileDialog.Options() options = self.__adjustOptions(options) if self.rOpenFile.isChecked() and self.__pyqtVariant == 4: QFileDialog.getOpenFileName(None, self.eCaption.text(), self.eStartWith.text(), self.eFilters.text(), options) else: QFileDialog.getOpenFileNameAndFilter( None, self.eCaption.text(), self.eStartWith.text(), self.eFilters.text(), self.eInitialFilter.text(), options) elif self.rOpenFiles.isChecked() or self.rfOpenFiles.isChecked(): if not self.cSymlinks.isChecked(): options = QFileDialog.Options(QFileDialog.DontResolveSymlinks) else: options = QFileDialog.Options() options = self.__adjustOptions(options) if self.rOpenFiles.isChecked() and self.__pyqtVariant == 4: QFileDialog.getOpenFileNames(None, self.eCaption.text(), self.eStartWith.text(), self.eFilters.text(), options) else: QFileDialog.getOpenFileNamesAndFilter( None, self.eCaption.text(), self.eStartWith.text(), self.eFilters.text(), self.eInitialFilter.text(), options) elif self.rSaveFile.isChecked() or self.rfSaveFile.isChecked(): if not self.cSymlinks.isChecked(): options = QFileDialog.Options(QFileDialog.DontResolveSymlinks) else: options = QFileDialog.Options() options = self.__adjustOptions(options) if self.rSaveFile.isChecked() and self.__pyqtVariant == 4: QFileDialog.getSaveFileName(None, self.eCaption.text(), self.eStartWith.text(), self.eFilters.text(), options) else: QFileDialog.getSaveFileNameAndFilter( None, self.eCaption.text(), self.eStartWith.text(), self.eFilters.text(), self.eInitialFilter.text(), options) elif self.rDirectory.isChecked(): options = QFileDialog.Options() if not self.cSymlinks.isChecked(): options |= QFileDialog.Options(QFileDialog.DontResolveSymlinks) if self.cDirOnly.isChecked(): options |= QFileDialog.Options(QFileDialog.ShowDirsOnly) else: options |= QFileDialog.Options(QFileDialog.Option(0)) options = self.__adjustOptions(options) QFileDialog.getExistingDirectory(None, self.eCaption.text(), self.eWorkDir.text(), options)
def getOpenFileNamesAndFilter(parent=None, caption="", directory="", filter="", initialFilter="", options=QFileDialog.Options()): """ Module function to get a list of names of files for opening and the selected file name filter. @param parent parent widget of the dialog (QWidget) @param caption window title of the dialog (string) @param directory working directory of the dialog (string) @param filter filter string for the dialog (string) @param initialFilter initial filter for the dialog (string) @param options various options for the dialog (QFileDialog.Options) @return list of file names to be opened and selected filter (list of string, string) """ if Globals.isLinuxPlatform(): options |= QFileDialog.DontUseNativeDialog newfilter = __reorderFilter(filter, initialFilter) if PYQT_VERSION_STR >= "5.0.0": return QFileDialog.getOpenFileNames(parent, caption, directory, newfilter, initialFilter, options) else: return QFileDialog.getOpenFileNamesAndFilter(parent, caption, directory, newfilter, initialFilter, options)
def on_bTest_clicked(self): """ Private method to test the selected options. """ if self.rOpenFile.isChecked() or self.rfOpenFile.isChecked(): if not self.cSymlinks.isChecked(): options = QFileDialog.Options(QFileDialog.DontResolveSymlinks) else: options = QFileDialog.Options() options = self.__adjustOptions(options) if self.rOpenFile.isChecked() and self.__pyqtVariant == 4: QFileDialog.getOpenFileName( None, self.eCaption.text(), self.eStartWith.text(), self.eFilters.text(), options) else: QFileDialog.getOpenFileNameAndFilter( None, self.eCaption.text(), self.eStartWith.text(), self.eFilters.text(), self.eInitialFilter.text(), options) elif self.rOpenFiles.isChecked() or self.rfOpenFiles.isChecked(): if not self.cSymlinks.isChecked(): options = QFileDialog.Options(QFileDialog.DontResolveSymlinks) else: options = QFileDialog.Options() options = self.__adjustOptions(options) if self.rOpenFiles.isChecked() and self.__pyqtVariant == 4: QFileDialog.getOpenFileNames( None, self.eCaption.text(), self.eStartWith.text(), self.eFilters.text(), options) else: QFileDialog.getOpenFileNamesAndFilter( None, self.eCaption.text(), self.eStartWith.text(), self.eFilters.text(), self.eInitialFilter.text(), options) elif self.rSaveFile.isChecked() or self.rfSaveFile.isChecked(): if not self.cSymlinks.isChecked(): options = QFileDialog.Options(QFileDialog.DontResolveSymlinks) else: options = QFileDialog.Options() options = self.__adjustOptions(options) if self.rSaveFile.isChecked() and self.__pyqtVariant == 4: QFileDialog.getSaveFileName( None, self.eCaption.text(), self.eStartWith.text(), self.eFilters.text(), options) else: QFileDialog.getSaveFileNameAndFilter( None, self.eCaption.text(), self.eStartWith.text(), self.eFilters.text(), self.eInitialFilter.text(), options) elif self.rDirectory.isChecked(): options = QFileDialog.Options() if not self.cSymlinks.isChecked(): options |= QFileDialog.Options(QFileDialog.DontResolveSymlinks) if self.cDirOnly.isChecked(): options |= QFileDialog.Options(QFileDialog.ShowDirsOnly) else: options |= QFileDialog.Options(QFileDialog.Option(0)) options = self.__adjustOptions(options) QFileDialog.getExistingDirectory( None, self.eCaption.text(), self.eWorkDir.text(), options)