https://bugzilla.redhat.com/show_bug.cgi?id=2258467
Bug ID: 2258467 Summary: PyQt6 and PyQt5 ignore "dir" argument in QFileDialog.getOpenFileName Product: Fedora Version: 38 Hardware: x86_64 OS: Linux Status: NEW Component: python-pyqt6 Severity: medium Assignee: thunderbirdtr@fedoraproject.org Reporter: Michael.Clerx@gmail.com CC: epel-packagers-sig@lists.fedoraproject.org, jonathan@almalinux.org, kde-sig@lists.fedoraproject.org, manisandro@gmail.com, thunderbirdtr@fedoraproject.org Target Milestone: --- Classification: Fedora
Since some time in 2021 (https://bugreports.qt.io/browse/QTBUG-92961, https://stackoverflow.com/questions/75878424) I've been running into an issue where QFileDialog.getOpenFileName ignores the "dir" argument (recently renamed "directory"):
QtWidgets.QFileDialog.getOpenFileName( self, 'Open file', '/home/michael/some/path', )
This is supposed to create an open file dialog initialised at "/home/michael/some/path", but at some point (around Fedora 33?) this stopped working.
The same functionality for getSaveFileName() works as expected.
I've only just noticed that the bug disappears if I install PyQt5 or PyQt6 into a virtual environment using pip, even when I specify the exact same versions that DNF installs. So it looks like this is an issue with the packaged version only. Because it's been present for quite a while now, I can't pinpoint where it was introduced, but I have seen the same bug on multiple devices, and in fresh installs of a variety of versions.
A script to reproduce:
#!/usr/bin/env python3 import sys from PyQt6 import QtWidgets #from PyQt5 import QtWidgets
# Change this to a valid & accessible path (other than your home) path = '/home/michael/a/path/that/definitely/exists'
class App(QtWidgets.QMainWindow): def __init__(self, path): super().__init__() self.setWindowTitle('Qt bug test') QtWidgets.QFileDialog.getOpenFileName(self, 'Open file', path)[0] sys.exit()
if __name__ == '__main__': a = QtWidgets.QApplication([]) a.lastWindowClosed.connect(a.quit) app = App(path) app.show() sys.exit(a.exec())
Reproducible: Always
Steps to Reproduce: 1. Change the `path` variable to an existing path, which you can access, but which isn't your home directory 2. Run the example code using PyQt5 or PyQt6 installed through DNF
Actual Results: An open file dialog appears showing the contents of your home directory
Expected Results: An open file dialog appears showing the contents of `path`
https://bugzilla.redhat.com/show_bug.cgi?id=2258467
Sandro Mani manisandro@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Doc Type|--- |If docs needed, set a value Flags| |needinfo?(Michael.Clerx@gma | |il.com)
--- Comment #1 from Sandro Mani manisandro@gmail.com --- Cannot reproduce this with either python3-pyqt6-6.6.1-4.fc40 or python3-qt5-5.15.10-4.fc40. Can you reproduce this with a clean install (i.e. in a virtualbox)?
https://bugzilla.redhat.com/show_bug.cgi?id=2258467
Michael Clerx Michael.Clerx@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Flags|needinfo?(Michael.Clerx@gma | |il.com) |
--- Comment #2 from Michael Clerx Michael.Clerx@gmail.com --- I cannot reproduce this in a clean install of Fedora 39. But I can reproduce it in a clean install of 38, and then all the way back to 32 (but not in 31).
I'm glad it works again in 39, but might be good to have a test or something to make sure it doesn't reoccur in newer versions?
https://bugzilla.redhat.com/show_bug.cgi?id=2258467
--- Comment #3 from Sandro Mani manisandro@gmail.com ---
But I can reproduce it in a clean install of 38, and then all the way back to 32 (but not in 31).
Clean and up-to-date F38?
https://bugzilla.redhat.com/show_bug.cgi?id=2258467
--- Comment #4 from Michael Clerx Michael.Clerx@gmail.com --- Yes I can recreate the problem with
1. Clean install of F38 2. dnf install python3-pyqt5 (or 6)
and with
1. Clean install of F38 2. dnf install python3-pyqt5 (or 6) 3. dnf update -y
https://bugzilla.redhat.com/show_bug.cgi?id=2258467
Sandro Mani manisandro@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |WONTFIX Status|NEW |CLOSED Last Closed| |2024-05-27 13:29:10
--- Comment #5 from Sandro Mani manisandro@gmail.com --- F38 ist EOL.
epel-packagers-sig@lists.fedoraproject.org