本文整理汇总了Python中PyQt5.QtWidgets.QFileDialog.getOpenFileNames方法的典型用法代码示例。如果您正苦于以下问题:Python QFileDialog.getOpenFileNames方法的具体用法?Python QFileDialog.getOpenFileNames怎么用?Python QFileDialog.getOpenFileNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QFileDialog
的用法示例。
在下文中一共展示了QFileDialog.getOpenFileNames方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _handle_multiple_files
# 需要导入模块: from PyQt5.QtWidgets import QFileDialog [as 别名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getOpenFileNames [as 别名]
def _handle_multiple_files(self, info, files):
"""Handle uploading of multiple files.
Loosely based on Helpviewer/HelpBrowserWV.py from eric5.
Args:
info: The ChooseMultipleFilesExtensionOption instance.
files: The ChooseMultipleFilesExtensionReturn instance to write
return values to.
Return:
True on success, the superclass return value on failure.
"""
suggested_file = ""
if info.suggestedFileNames:
suggested_file = info.suggestedFileNames[0]
files.fileNames, _ = QFileDialog.getOpenFileNames(
None, None, suggested_file) # type: ignore[arg-type]
return True
示例2: prompt_extractor
# 需要导入模块: from PyQt5.QtWidgets import QFileDialog [as 别名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getOpenFileNames [as 别名]
def prompt_extractor(self, item):
extractor = extractors[item.data(Qt.UserRole)]
inputs = []
if not assert_installed(self.view, **extractor.get('depends', {})):
return
if not extractor.get('pick_url', False):
files, mime = QFileDialog.getOpenFileNames()
for path in files:
inputs.append((path, Path(path).stem))
else:
text, good = QInputDialog.getText(self.view, ' ', 'Input an URL:')
if text:
url = urlparse(text)
inputs.append((url.geturl(), url.netloc))
if inputs:
wait = QProgressDialog('Extracting .proto structures...', None, 0, 0)
wait.setWindowTitle(' ')
self.set_view(wait)
self.worker = Worker(inputs, extractor)
self.worker.progress.connect(self.extraction_progress)
self.worker.finished.connect(self.extraction_done)
self.worker.start()
示例3: addSongFile
# 需要导入模块: from PyQt5.QtWidgets import QFileDialog [as 别名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getOpenFileNames [as 别名]
def addSongFile(self):
urls, _ = QFileDialog.getOpenFileNames(
caption="Select one or more files to open",
directory="/home",
filter="music(*mp2 *.mp3 *.mp4 *.m4a *wma *wav)")
if urls:
self.addSongFiles(urls)
示例4: add_uri_audio_media_cue
# 需要导入模块: from PyQt5.QtWidgets import QFileDialog [as 别名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getOpenFileNames [as 别名]
def add_uri_audio_media_cue():
"""Add audio MediaCue(s) form user-selected files"""
if get_backend() is None:
QMessageBox.critical(MainWindow(), 'Error', 'Backend not loaded')
return
# Default path to system "music" folder
path = QStandardPaths.writableLocation(QStandardPaths.MusicLocation)
# Get the backend extensions and create a filter for the Qt file-dialog
extensions = get_backend().supported_extensions()
filters = qfile_filters(extensions, anyfile=False)
# Display a file-dialog for the user to choose the media-files
files, _ = QFileDialog.getOpenFileNames(MainWindow(),
translate('MediaCueMenus',
'Select media files'),
path, filters)
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
# Create media cues, and add them to the Application cue_model
for file in files:
cue = CueFactory.create_cue('URIAudioCue', uri='file://' + file)
# Use the filename without extension as cue name
cue.name = os.path.splitext(os.path.basename(file))[0]
Application().cue_model.add(cue)
QApplication.restoreOverrideCursor()
示例5: import_files_clicked
# 需要导入模块: from PyQt5.QtWidgets import QFileDialog [as 别名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getOpenFileNames [as 别名]
def import_files_clicked(self):
paths, x = QFileDialog.getOpenFileNames(
self, _("TEXT_FILE_IMPORT_FILES"), self.default_import_path
)
if not paths:
return
files, total_size = self.get_files(paths)
f = files[0][0]
self.default_import_path = str(f.parent)
self.import_all(files, total_size)
示例6: onAddSongs
# 需要导入模块: from PyQt5.QtWidgets import QFileDialog [as 别名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getOpenFileNames [as 别名]
def onAddSongs(self):
file_names, a = self.gui.getOpenFileName('Add Songs',
'Super Boucle Song (*.sbs)',
self,
QFileDialog.getOpenFileNames)
self.gui.playlist += file_names # getSongs(file_names)
self.updateList()
示例7: select_files
# 需要导入模块: from PyQt5.QtWidgets import QFileDialog [as 别名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getOpenFileNames [as 别名]
def select_files(directory_location=None):
qtapp = QApplication([directory_location])
qtwgt = QtWidgets.QWidget()
filenames, _ = QFileDialog.getOpenFileNames(qtwgt)
return filenames
示例8: on_file_dialog
# 需要导入模块: from PyQt5.QtWidgets import QFileDialog [as 别名]
# 或者: from PyQt5.QtWidgets.QFileDialog import getOpenFileNames [as 别名]
def on_file_dialog(self, dialog_type, directory, allow_multiple, save_filename, file_filter):
if dialog_type == FOLDER_DIALOG:
self._file_name = QFileDialog.getExistingDirectory(self, localization['linux.openFolder'], options=QFileDialog.ShowDirsOnly)
elif dialog_type == OPEN_DIALOG:
if allow_multiple:
self._file_name = QFileDialog.getOpenFileNames(self, localization['linux.openFiles'], directory, file_filter)
else:
self._file_name = QFileDialog.getOpenFileName(self, localization['linux.openFile'], directory, file_filter)
elif dialog_type == SAVE_DIALOG:
if directory:
save_filename = os.path.join(str(directory), str(save_filename))
self._file_name = QFileDialog.getSaveFileName(self, localization['global.saveFile'], save_filename)
self._file_name_semaphore.release()