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

Retrieve the true file path using QFileDialog #72

Open tdard opened 1 year ago

tdard commented 1 year ago

Hi,

I try to get the path to an existing file, but the resulting path has a weird prefix, like it is moved in a temporary directory: for a file located at /home/<user_name>/<folder_name>/<file_name.extension> I obtain the following path: /run/user/1000/doc/daf242de/<file_name.extension>

Here is the sample code (tested on Ubuntu)

if __name__ == "__main__":
    from PyQt5.QtWidgets import QApplication, QFileDialog

    app = QApplication([])

    dialog = QFileDialog()
    dialog.setFileMode(QFileDialog.ExistingFile)  # Accept a single file that exists
    if dialog.exec():
        file_path = dialog.selectedFiles[0]
        print(file_path)

Do you know if it is normal, and how I could I configure the dialog such that I could retrieve the true path of the file I'm searching for? Kind regards