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`
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)?
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?
> 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?
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
F38 ist EOL.