本文整理汇总了Python中PyQt5.QtWidgets.QFileDialog.ShowDirsOnly方法的典型用法代码示例。如果您正苦于以下问题:Python QFileDialog.ShowDirsOnly方法的具体用法?Python QFileDialog.ShowDirsOnly怎么用?Python QFileDialog.ShowDirsOnly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QFileDialog
的用法示例。
在下文中一共展示了QFileDialog.ShowDirsOnly方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_Window_get_microbit_path
# 需要导入模块: from PyQt5.QtWidgets import QFileDialog [as 别名]
# 或者: from PyQt5.QtWidgets.QFileDialog import ShowDirsOnly [as 别名]
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
)
示例2: choose_folder_dialog
# 需要导入模块: from PyQt5.QtWidgets import QFileDialog [as 别名]
# 或者: from PyQt5.QtWidgets.QFileDialog import ShowDirsOnly [as 别名]
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
示例3: browse_external_transfer_files
# 需要导入模块: from PyQt5.QtWidgets import QFileDialog [as 别名]
# 或者: from PyQt5.QtWidgets.QFileDialog import ShowDirsOnly [as 别名]
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)
示例4: choose_file_dialog
# 需要导入模块: from PyQt5.QtWidgets import QFileDialog [as 别名]
# 或者: from PyQt5.QtWidgets.QFileDialog import ShowDirsOnly [as 别名]
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
示例5: _select_output_directory
# 需要导入模块: from PyQt5.QtWidgets import QFileDialog [as 别名]
# 或者: from PyQt5.QtWidgets.QFileDialog import ShowDirsOnly [as 别名]
def _select_output_directory(self):
dir_name = QFileDialog.getExistingDirectory(directory=self.last_output_live_dir,
options=QFileDialog.ShowDirsOnly)
self._set_output_directory(dir_name)
示例6: on_dictDirButton_clicked
# 需要导入模块: from PyQt5.QtWidgets import QFileDialog [as 别名]
# 或者: from PyQt5.QtWidgets.QFileDialog import ShowDirsOnly [as 别名]
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)
示例7: on_pbTessData_clicked
# 需要导入模块: from PyQt5.QtWidgets import QFileDialog [as 别名]
# 或者: from PyQt5.QtWidgets.QFileDialog import ShowDirsOnly [as 别名]
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)
示例8: get_directory
# 需要导入模块: from PyQt5.QtWidgets import QFileDialog [as 别名]
# 或者: from PyQt5.QtWidgets.QFileDialog import ShowDirsOnly [as 别名]
def get_directory():
directory = QFileDialog.getExistingDirectory(None, "Choose Directory", QDir.homePath(),
QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks)
return directory
示例9: on_file_dialog
# 需要导入模块: from PyQt5.QtWidgets import QFileDialog [as 别名]
# 或者: from PyQt5.QtWidgets.QFileDialog import ShowDirsOnly [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()