如何进行目录对话框 [英] how to have a directory dialog
本文介绍了如何进行目录对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在PyQt中,如何显示一个文件浏览器,该浏览器仅显示和选择目录(而不是文件)?
In PyQt, how does one display a file browser that shows and selects only directories (not files)?
又如何检索所选目录的名称?
And how does one retrieve the name of the selected directory?
推荐答案
从QDialog/QWidget类内部,您应该能够做到:
From inside your QDialog/QWidget class, you should be able to do:
file = str(QFileDialog.getExistingDirectory(self, "Select Directory"))
这篇关于如何进行目录对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文