本文整理匯總了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) )