I used to be able to set an initial directory for the native open-file dialog in PyQt5, PyQt6, PySide2 etc. using code like this:
QtWidgets.QFileDialog.getOpenFileName(
self,
'Open file',
'/home/michael/last_path',
)
where the 3d argument is a str
specifying the initial directory for the dialog.
On recent versions of Fedora (running either wayland or X11), the directory argument is silently ignored.
Strangely, it does still work for getSaveFileName
.
Does anybody have any idea what's going on? Or where I could report this? (Qt? Fedora devs?) Or similarly, where I could look to start fixing this myself?
Update with more version info:
Currently on Fedora 37 with Gnome 43.3, but problem has been around for a while now, going back to Fedora 33 at least, if I remember correctly. Same problem on two different machines. Also seen it in software not written by me but also using Python & Qt (e.g. Veusz).
Thought at first it was a Wayland thing, but checked after comment below from @relent95 and actually happens on X11 too.
I've now confirmed that it works when I install PyQt5 or PyQt6 into a virtualenv with pip
, but fails when I use the dnf
installed PyQt5 or PyQt6. So possibly a fedora packaging issue?
Seems to have been a bug in packaged PyQt from Fedora 32 onwards, but fixed in 39.