how to have a directory dialog

Moayyad Yaghi picture Moayyad Yaghi · Nov 26, 2010 · Viewed 51k times · Source

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?

Answer

TZHX picture TZHX · Nov 26, 2010

From inside your QDialog/QWidget class, you should be able to do:

file = str(QFileDialog.getExistingDirectory(self, "Select Directory"))