Search code examples
pythonpyqtpyqt4file-browser

how to have a directory dialog


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?


Solution

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

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