[PyQt] Bug in QFileDialog for PyQt5 / Qt5.7 ?
Maxwell Grady
max.grady at gmail.com
Thu Dec 1 18:31:05 GMT 2016
>>> from PyQt5 import QtWidgets
>>> app = QtWidgets.QApplication([''])
>>> QtWidgets.QFileDialog.getOpenFileNames()
(['/usr/lib/python3.5/re.py', '/usr/lib/python3.5/os.py',
'/usr/lib/python3.5/io.py'], 'All Files (*)')
This code works correctly for me as well on OS X.11 with PyQt5 via Anaconda
The method returns a tuple containing two items. The first of which is a
list of file paths and the second is the file filter that was active when
selecting files.
-Maxwell
On Thu, Dec 1, 2016 at 1:19 PM, Baz Walter <bazwal at ftml.net> wrote:
> On 01/12/16 12:26, Massimo Vassalli wrote:
>
>> Dear all,
>>
>> I found a strange behaviour (a bug ?) In the new implementation
>> of QFileDialog I'm using with Qt5.7 / PyQt5.7.
>>
>> In short, the static function QFileDialog.getOpenFileNames() which is
>> expected to let the user selet more than one file and return a list, does
>> only half of the job. The dialog is executed with FileMode set to
>> QFileDialog.ExistingFiles (so that the user can select more than one file)
>> but the function returns only the first file of the list (the first
>> clicked
>> file, to be precise). A workaround is to instantiate the class QFileDialog
>> and use it:
>>
>> q = QtWidgets.QFileDialog()
>> q.setAcceptMode(QtWidgets.QFileDialog.AcceptOpen)
>> q.setFileMode(QtWidgets.QFileDialog.ExistingFiles)
>> fnames = q.selectedFiles()
>>
>> Should it be considered a bug or was I wrong in using the static function
>> ?
>>
>
> Works okay for me:
>
> >>> from PyQt5 import QtWidgets
> >>> app = QtWidgets.QApplication([''])
> >>> QtWidgets.QFileDialog.getOpenFileNames()
> (['/usr/lib/python3.5/re.py', '/usr/lib/python3.5/os.py',
> '/usr/lib/python3.5/io.py'], 'All Files (*)')
>
> _______________________________________________
> PyQt mailing list PyQt at riverbankcomputing.com
> https://www.riverbankcomputing.com/mailman/listinfo/pyqt
--
University of New Hampshire
Department of Physics
Pohl Group
DeMeritt Hall 119
---
Síocháin agus Grá
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20161201/5e6f1792/attachment.html>
More information about the PyQt
mailing list