[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] QFileDialog.getOpenFileName returns a tuple?
From:       David Cortesi <davecortesi () gmail ! com>
Date:       2014-03-22 18:05:13
Message-ID: CALyzANtVvx9XuWmtrcna+9J3ScGrvYonhNzbXa4Hay_KJMNi0g () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


In converting a PyQt4 program to PyQt5 I ran into an error because under
PyQt5 (5.2), QFileDialog.getOpenFileName() returns a tuple of two strings.
The first is either a path or null depending on the Cancel button, and the
second always null.

According to the C++ doc for getOpenFileName [1], the returned value is a
string, and "If the user presses Cancel, it returns a null string." In the
PyQt4 doc [2] it shows getOpenFileName returning a string (although it
mentions that the three get...Filter methods return tuples).

Was the behavior of getOpenFileName changed deliberately or is this a bug?

Thanks,
Dave Cortesi

[1] http://qt-project.org/doc/qt-5/qfiledialog.html#getOpenFileName
[2] http://pyqt.sourceforge.net/Docs/PyQt4/python_v3.html#qfiledialog

[Attachment #5 (text/html)]

<div dir="ltr"><div><div><div><div>In converting a PyQt4 program to PyQt5 I ran into an error \
because under PyQt5 (5.2), QFileDialog.getOpenFileName() returns a tuple of two strings. The \
first is either a path or null depending on the Cancel button, and the second always null.<br>

<br>According to the C++ doc for getOpenFileName [1], the returned value is a string, and \
&quot;<span style="color:rgb(54,53,52);font-family:&#39;Open \
Sans&#39;,sans-serif;font-size:13px;font-style:normal;font-variant:normal;font-weight:normal;let \
ter-spacing:normal;line-height:20px;text-align:left;text-indent:0px;text-transform:none;white-sp \
ace:normal;word-spacing:0px;background-color:rgb(255,255,255);display:inline!important;float:none">If \
the user presses Cancel, it returns a null string.&quot;</span> In the PyQt4 doc [2] it shows \
getOpenFileName returning a string (although it mentions that the three get...Filter methods \
return tuples).<br>

</div><br></div>Was the behavior of getOpenFileName changed deliberately or is this a \
bug?<br><br></div>Thanks,<br></div>Dave Cortesi<br><div><div><div><div><br>[1] <a \
href="http://qt-project.org/doc/qt-5/qfiledialog.html#getOpenFileName">http://qt-project.org/doc/qt-5/qfiledialog.html#getOpenFileName</a><br>


[2] <a href="http://pyqt.sourceforge.net/Docs/PyQt4/python_v3.html#qfiledialog">http://pyqt.sour \
ceforge.net/Docs/PyQt4/python_v3.html#qfiledialog</a><br></div></div></div></div></div>



_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic