使FileChooserDialog允许用户选择一个文件夹/目录 [英] Make FileChooserDialog allow user to select a folder/directory
本文介绍了使FileChooserDialog允许用户选择一个文件夹/目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
能否在gtk.FileChooserDialog / gtk.FileChooserButton设置为仅允许用户选择一个文件夹/目录?
也许我添加目录过滤器来实现这一目标?
email_dialog = gtk.FileChooserDialog(title =选择文件夹)如何使用户只能选择文件夹? ,
按钮=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
email_filter = gtk.FileFilter()
email_filter.set_name( 文件夹)
email_filter.add_pattern(*)#文件夹的格式是什么
email_dialog.add_filter(email_filter)
< DIV类= h2_lin>解决方案
email_dialog.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
文档这里。
Can a gtk.FileChooserDialog/gtk.FileChooserButton be set to only allow users to select a folder/directory?
Maybe I add a directory filter to achieve this? How can I make it so the user can only select a folder?
email_dialog = gtk.FileChooserDialog(title="Select folder",
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK))
email_filter = gtk.FileFilter()
email_filter.set_name("Folder")
email_filter.add_pattern("*") # whats the pattern for a folder
email_dialog.add_filter(email_filter)
解决方案
email_dialog.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
Documentation here.
这篇关于使FileChooserDialog允许用户选择一个文件夹/目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文