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

PyQt5 uses directory instead of dir for members of QFileDialog #321

Open
jasperges opened this issue Aug 2, 2019 · 5 comments
Open

PyQt5 uses directory instead of dir for members of QFileDialog #321

jasperges opened this issue Aug 2, 2019 · 5 comments

Comments

@jasperges
Copy link

In all bindings you have the keyword argument dir for members of QFileDialog, but in PyQt5 it is directory (personally I think it's better because it doesn't redefine a built-in). For example QFileDialog.getOpenFilename(dir="/home/me") would be QFileDialog.getOpenFileName(directory="/home/me") in PyQt5.

I have no idea how difficult this would be, but personally I think the best solution would be that you can use either dir or directory. If that would be impractical, I would suggest dir because that is used by the majority of bindings.

@BigRoy
Copy link

BigRoy commented Aug 2, 2019

@jasperges Are you sure? It seems to only use directory for __init__ but the static methods still use dir according to this: https://doc.qt.io/qt-5/qfiledialog.html#getOpenFileName right?

Or is this old documentation?


Edit:

Also the PyQt5 documentation doesn't state that as a change from PyQt4 at all, interestingly enough. And this just points to the C++ documentation that lists the same dir argument (same page)

Seems like someone over-refactored the code and left it undocumented? :)

@jasperges
Copy link
Author

jasperges commented Aug 2, 2019

@BigRoy Yes, I'm sure. :) See here.

I used to like the documentation of PyQt better then the one from PySide. But's that's now totally reversed.

@BigRoy
Copy link

BigRoy commented Aug 2, 2019

@mottosso note that PySide2 and PyQt5 do it differenty as Jasper describes here

As far as I can tell PyQt5 uses directory everywhere, where PySide2 (and also PyQt4) use dir.

What's the Qt.py way to fix this one? ;)

@mottosso
Copy link
Owner

mottosso commented Aug 4, 2019

Me and Jasper chatted about this prior to making an issue out of it, and decided it wasn't worth handling through Qt.py.

Initially we thought of making a QtCompat member.

QtCompat.getOpenFilename()

But there are quite a few of these static members that are presumably all wrong (in PyQt) that we would need to add and I'd like to avoid having too much of anyone's code being calls to QtCompat; it should be rare.

The other option is "fixing" the original calls, like we've done by forwarding things from Qt 4's QtGui to QtWidgets for example. That would be the ideal option, as it would mean code you write with PySide also works in PyQt and vice versa. It just isn't clear how complex that would be, but a pull-request is welcome.

And for completeness, the "correct" one would be dir, simply because that's what PySide2 does, and Qt.py is all about making PySide2's interface work with all bindings. (It's also in the corresponding C++ call)

@MHendricks
Copy link
Collaborator

Qt.QtCompat.QFileDialog already provides a compatibility specifically for the PyQt4 static members getOpenFileName, getOpenFileNames and getSaveFileName return not matching the other bindings. It should be possible to implement a method for PyQt5 similar to the _standardizeQFileDialog decorator used in the PyQt4 bindings that adjusts the kwargs before passing them to PyQt5.

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

4 participants