Python PyQt5.QtWidgets.QFileDialog.getOpenFileNames() Examples

The following are 8 code examples of PyQt5.QtWidgets.QFileDialog.getOpenFileNames(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PyQt5.QtWidgets.QFileDialog , or try the search function .
Example #1
Source File: webpage.py    From qutebrowser with GNU General Public License v3.0 6 votes vote down vote up
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 
Example #2
Source File: gui.py    From pbtk with GNU General Public License v3.0 6 votes vote down vote up
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() 
Example #3
Source File: muscimanageworker.py    From QMusic with GNU Lesser General Public License v2.1 5 votes vote down vote up
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) 
Example #4
Source File: media_cue_menus.py    From linux-show-player with GNU General Public License v3.0 5 votes vote down vote up
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() 
Example #5
Source File: files_widget.py    From parsec-cloud with GNU Affero General Public License v3.0 5 votes vote down vote up
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) 
Example #6
Source File: playlist.py    From superboucle with GNU General Public License v3.0 5 votes vote down vote up
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() 
Example #7
Source File: select_file_pyqt.py    From Awesome-Python-Scripts with MIT License 5 votes vote down vote up
def select_files(directory_location=None):
	qtapp = QApplication([directory_location])
	qtwgt = QtWidgets.QWidget()
	filenames, _ = QFileDialog.getOpenFileNames(qtwgt)
	return filenames 
Example #8
Source File: qt.py    From pywebview with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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()