pyqt / python-qt5

Unofficial PyQt5 via PyPI for Python 2.7 64-bit on Windows
GNU General Public License v3.0
280 stars 77 forks source link

Directory cannot be chosen with DirectoryOnly file mode in QFileDialog #48

Open leungchikiissac opened 4 years ago

leungchikiissac commented 4 years ago

Only Directory which has name with dot (".") can be chosen.

qfiledialog.py

if __name__ == '__main__':
    from PyQt5.QtWidgets import QFileDialog, QApplication
    import sys
    app = QApplication(sys.argv)

    file_dialog = QFileDialog(None, "Select Directory Data", "", 'All Files(*.*)')
    file_dialog.setFileMode(QFileDialog.DirectoryOnly)

    dir_name = ""
    if file_dialog.exec_():
        dir_name = file_dialog.selectedFiles()[0]

    sys.exit(app.exec_())

System and software versions:

I run the qfiledialog.py in virtual environment with only PyQt5 installed manually. The file dialog pops up and the appearance is as the following. But as you see only the directory "with_dot." is in black color and can be chosen. But directory "test_directory" does not. Screenshot from 2019-10-23 15-52-45

I tried to run it with superuser command (sudo). All directory works fine right now. But I guess it is not expected to be only worked with root privilege. I also check the file permissions. I suspect nothing related to the directory's file permissions since directory "with_dot." and "test_directory" have identical status of the permission. Screenshot from 2019-10-23 16-11-18

OOOlledj commented 3 years ago

Met the same issue: can not choose folder with "DirectoryOnly" FileMode:

def callFileDialog(self):
        self.fileDialog = QFileDialog()
        self.fileDialog.setFileMode(QFileDialog.DirectoryOnly)

Screenshot_2021-02-12_00-33-34