Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve the true file path using QFileDialog #72

Open
tdard opened this issue Jul 29, 2022 · 0 comments
Open

Retrieve the true file path using QFileDialog #72

tdard opened this issue Jul 29, 2022 · 0 comments

Comments

@tdard
Copy link

tdard commented Jul 29, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant