本文整理匯總了Python中Windows.browse_folder方法的典型用法代碼示例。如果您正苦於以下問題:Python Windows.browse_folder方法的具體用法?Python Windows.browse_folder怎麽用?Python Windows.browse_folder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Windows
的用法示例。
在下文中一共展示了Windows.browse_folder方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: browse_folder
# 需要導入模塊: import Windows [as 別名]
# 或者: from Windows import browse_folder [as 別名]
def browse_folder(parent, title, multiple, stock_button):
"""Ask the user to select a folder. Return the full path or None."""
if 'nt' == os.name and None == os.getenv('BB_NATIVE'):
ret = Windows.browse_folder(
parent.window.handle if parent else None, title)
return [ret] if multiple and not ret is None else ret
# fall back to GTK+
chooser = gtk.FileChooserDialog(parent=parent,
title=title,
buttons=(
gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
stock_button, gtk.RESPONSE_OK),
action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
chooser.set_select_multiple(multiple)
chooser.set_current_folder(os.path.expanduser('~'))
resp = chooser.run()
if multiple:
ret = chooser.get_filenames()
else:
ret = chooser.get_filename()
chooser.hide()
chooser.destroy()
if gtk.RESPONSE_OK != resp:
# user cancelled
return None
return ret