Python PyQt5.QtWidgets.QFileDialog.ShowDirsOnly() Examples

The following are 9 code examples of PyQt5.QtWidgets.QFileDialog.ShowDirsOnly(). 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: settings_dialog.py    From uPyLoader with MIT License 6 votes vote down vote up
def browse_external_transfer_files(self):
        path = QFileDialog().getExistingDirectory(
            caption="Select transfer files folder",
            directory=QDir().homePath(),
            options=QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks)

        if path:
            self.transferFilesPathLineEdit.setText(path) 
Example #2
Source File: test_main.py    From mu with GNU General Public License v3.0 6 votes vote down vote up
def test_Window_get_microbit_path(qtapp):
    """
    Ensures the QFileDialog is called with the expected arguments and the
    resulting path is returned.
    """
    mock_fd = mock.MagicMock()
    path = "/foo"
    ShowDirsOnly = QFileDialog.ShowDirsOnly
    mock_fd.getExistingDirectory = mock.MagicMock(return_value=path)
    mock_fd.ShowDirsOnly = ShowDirsOnly
    w = mu.interface.main.Window()
    w.widget = mock.MagicMock()
    with mock.patch("mu.interface.main.QFileDialog", mock_fd):
        assert w.get_microbit_path("micropython") == path
    title = "Locate BBC micro:bit"
    mock_fd.getExistingDirectory.assert_called_once_with(
        w.widget, title, "micropython", ShowDirsOnly
    ) 
Example #3
Source File: utils.py    From restatic with GNU General Public License v3.0 5 votes vote down vote up
def choose_folder_dialog(parent, title):
    options = QFileDialog.Options()
    options |= QFileDialog.ShowDirsOnly
    dialog = QFileDialog(parent, title, os.path.expanduser("~"), options=options)
    dialog.setFileMode(QFileDialog.Directory)
    dialog.setParent(parent, QtCore.Qt.Sheet)
    return dialog 
Example #4
Source File: utils.py    From vorta with GNU General Public License v3.0 5 votes vote down vote up
def choose_file_dialog(parent, title, want_folder=True):
    options = QFileDialog.Options()
    if want_folder:
        options |= QFileDialog.ShowDirsOnly
    dialog = QFileDialog(parent, title, os.path.expanduser('~'), options=options)
    dialog.setFileMode(QFileDialog.Directory if want_folder else QFileDialog.AnyFile)
    dialog.setParent(parent, QtCore.Qt.Sheet)
    return dialog 
Example #5
Source File: gui.py    From PUBGIS with GNU General Public License v3.0 5 votes vote down vote up
def _select_output_directory(self):
        dir_name = QFileDialog.getExistingDirectory(directory=self.last_output_live_dir,
                                                    options=QFileDialog.ShowDirsOnly)
        self._set_output_directory(dir_name) 
Example #6
Source File: settingsdialog.py    From lector with GNU General Public License v2.0 5 votes vote down vote up
def on_dictDirButton_clicked(self):
        dictDir = QFileDialog.getExistingDirectory(self,
                  self.tr("Choose your dictionary directory..."),
                  self.ui.directoryLine.text(),
                  QFileDialog.DontResolveSymlinks | QFileDialog.ShowDirsOnly)

        if not dictDir.isEmpty():
            self.ui.directoryLine.setText(dictDir)
            self.langList(dictDir) 
Example #7
Source File: settingsdialog.py    From lector with GNU General Public License v2.0 5 votes vote down vote up
def on_pbTessData_clicked(self):
        dictDir = QFileDialog.getExistingDirectory(self,
                  self.tr("Select Path Prefix To tessdata Directory..."),
                  self.ui.lnTessData.text(),
                  QFileDialog.DontResolveSymlinks | QFileDialog.ShowDirsOnly)

        if not dictDir.isEmpty():
            self.ui.lnTessData.setText(dictDir) 
Example #8
Source File: FileOperator.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def get_directory():
    directory = QFileDialog.getExistingDirectory(None, "Choose Directory", QDir.homePath(),
                                                 QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks)
    return directory 
Example #9
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()