本文整理汇总了Python中AnyQt.QtWidgets.QFileDialog.getExistingDirectory方法的典型用法代码示例。如果您正苦于以下问题:Python QFileDialog.getExistingDirectory方法的具体用法?Python QFileDialog.getExistingDirectory怎么用?Python QFileDialog.getExistingDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QFileDialog
的用法示例。
在下文中一共展示了QFileDialog.getExistingDirectory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __runOpenDialog
# 需要导入模块: from AnyQt.QtWidgets import QFileDialog [as 别名]
# 或者: from AnyQt.QtWidgets.QFileDialog import getExistingDirectory [as 别名]
def __runOpenDialog(self):
startdir = os.path.expanduser("~/")
if self.recent_paths:
startdir = os.path.dirname(self.recent_paths[0].abspath)
if OWImportImages.Modality == Qt.WindowModal:
dlg = QFileDialog(
self, "Select Top Level Directory", startdir,
acceptMode=QFileDialog.AcceptOpen,
modal=True,
)
dlg.setFileMode(QFileDialog.Directory)
dlg.setOption(QFileDialog.ShowDirsOnly)
dlg.setDirectory(startdir)
dlg.setAttribute(Qt.WA_DeleteOnClose)
@dlg.accepted.connect
def on_accepted():
dirpath = dlg.selectedFiles()
if dirpath:
self.setCurrentPath(dirpath[0])
self.start()
dlg.open()
else:
dirpath = QFileDialog.getExistingDirectory(
self, "Select Top Level Directory", startdir
)
if dirpath:
self.setCurrentPath(dirpath)
self.start()
示例2: save_project
# 需要导入模块: from AnyQt.QtWidgets import QFileDialog [as 别名]
# 或者: from AnyQt.QtWidgets.QFileDialog import getExistingDirectory [as 别名]
def save_project(self, project_path=None):
try:
if project_path is None:
project_path = QFileDialog.getExistingDirectory(self, "Select the project directory")
if project_path is not None and str(project_path)!='':
project_path = str(project_path)
self.save({}, project_path)
except Exception as e:
QMessageBox.critical(self, "Error", str(e))
示例3: load_project
# 需要导入模块: from AnyQt.QtWidgets import QFileDialog [as 别名]
# 或者: from AnyQt.QtWidgets.QFileDialog import getExistingDirectory [as 别名]
def load_project(self, project_path=None):
if project_path is None:
project_path = QFileDialog.getExistingDirectory(self, "Select the project directory")
if project_path is not None and str(project_path)!='':
self.load({}, str(project_path) )