[PyQt] QFileDialog static methods accept parameter 'directory' not 'dir' (pyqt 5.10.1)

Kyle Altendorf sda at fstab.net
Thu May 10 19:03:04 BST 2018


At least QFileSystem.getSaveFileName() and .getOpenFileName() expect a 
parameter 'directory' instead of the 'dir' that the Qt docs list.  I 
didn't test the rest of the static methods (or other standard methods)>.

docs: http://doc.qt.io/qt-5/qfiledialog.html#getSaveFileName
source: 
https://github.com/qt/qtbase/blob/e843e3bb00d26c841bd7132c00779c085368eab3/src/widgets/dialogs/qfiledialog.cpp#L2122

https://gist.github.com/altendky/140429fe1824901c398e06de627dfa43
----
$ venv/bin/pip install pyqt5
Collecting pyqt5
   Cache entry deserialization failed, entry ignored
   Using cached 
https://files.pythonhosted.org/packages/e4/15/4e2e49f64884edbab6f833c6fd3add24d7938f2429aec1f2883e645d4d8f/PyQt5-5.10.1-5.10.1-cp35.cp36.cp37.cp38-abi3-manylinux1_x86_64.whl
Collecting sip<4.20,>=4.19.4 (from pyqt5)
   Cache entry deserialization failed, entry ignored
   Using cached 
https://files.pythonhosted.org/packages/8a/ea/d317ce5696dda4df7c156cd60447cda22833b38106c98250eae1451f03ec/sip-4.19.8-cp36-cp36m-manylinux1_x86_64.whl
Installing collected packages: sip, pyqt5
from PyQt5 Successfully installed pyqt5-5.10.1 sip-4.19.8
You are using pip version 9.0.3, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' 
command.
$ venv/bin/python
Python 3.6.5 (default, Apr 29 2018, 18:05:11)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from PyQt5 import Qt
>>> app = Qt.QAppliation([])
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
AttributeError: module 'PyQt5.Qt' has no attribute 'QAppliation'
>>> app = Qt.QApplication([])
>>> Qt.QFileDialog.getSaveFileName(dir='/red')
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
TypeError: getSaveFileName(parent: QWidget = None, caption: str = '', 
directory: str = '', filter: str = '', initialFilter: str = '', options: 
Union[QFileDialog.Options, QFileDialog.Option] = 0): 'dir' is not a 
valid keyword argument
>>> Qt.QFileDialog.getSaveFileName(filter='')
('', '')
>>> Qt.QFileDialog.getSaveFileName(caption='')
('', '')
>>> Qt.QFileDialog.getSaveFileName(directory='/red')
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
KeyboardInterrupt
>>> Qt.QFileDialog.getSaveFileName(directory='/red')
('', '')
>>> Qt.QFileDialog.getOpenFileName(directory='/red')
('', '')
>>> Qt.QFileDialog.getOpenFileName(dir='/red')
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
TypeError: getOpenFileName(parent: QWidget = None, caption: str = '', 
directory: str = '', filter: str = '', initialFilter: str = '', options: 
Union[QFileDialog.Options, QFileDialog.Option] = 0): 'dir' is not a 
valid keyword argument
>>> 


More information about the PyQt mailing list