Pyqt5 - search documentation

I worked my way through the Summerfields book on Rapid GUI programming with Python and QT ... pyqt to be preciser, but the 2007 book uses version 4.something, and I'm trying to upgrade with the current version 5.4.2 ..

There are some changes that I'm trying to figure out, and I would like help in finding the material. Here is an example of a file save dialog - from a book:

    fname = QFileDialog.getSaveFileName(self,
            "Image Changer - Save Image", fname,
            "Image files ({})".format(" ".join(formats)))

This does not work, perhaps primarily because in pyqt5 it QFileDialogreturns a tuple, not a string. The only way to understand this is simply trial and error. The pyqt5 documentation relates to QT, which I really don't understand.

I got the following:

   fname = QFileDialog.getSaveFileName(self, 'some text',
            "whatever.png", '*.png')
   if "." not in fname[0]:
       fname[0] += ".png"
       self.addRecentFile(fname[0])
       self.filename = fname[0]
       return self.fileSave()

Wow, this works! But I'm just making progress. I tried running the python interpreter and typed:

from PyQt5.QtWidgets import  QFileDialog

help(QFileDialog)

() , , , getSaveFileName. - @$$.

?

+4
2

QFileDialog PyQt. , PyQt.

. Python, , . ++ , , , .

++ QFileDialog.getSaveFileName :

getSaveFileName(
    QWidget * parent = 0, const QString & caption = String(),
    const QString & dir = QString(), const QString & filter = QString(),
    QString * selectedFilter = 0, Options options = 0)

, QString . const , selectedFilter QString, , .

PyQt ++ ( Python), API API Qt. , PyQt-4.6 QFileDialog ++, :

>>> s = QString() # string to be modified
>>> f = QFileDialog.getSaveFileName(None, 'Save', '', 'Img(*.png *.jpg)', s)
>>> print s
Img(*.png *.jpg)

, PyQt4 ( , QString, ).

PyQt4 , Python , , , . getSaveFileName , , getSaveFileNameAndFilter, .

PyQt5 ( QString). , ( Python) getSaveFileName. : PyQt5, Qt-, , , .


(PS: PySide, PyQt, . QFileDialog ).

+5

QFileDialog , PyQt , Qt.

-, PyQt5 QFileDialog.getSaveFileName() QFileDialog.getSaveFileNameAndFilter() PyQt4 (source). -, QFileDialog.getSaveFileNameAndFilter() PyQt4 (filename, selectedFilter) (source).

, PyQt4 QFileDialog.getSaveFileNameAndFilter() -

getSaveFileNameAndFilter (QWidget parent = None, QString caption = QString(), 
                          QString directory = QString(), QString filter = QString(), 
                          QString initialFilter = QString(), Options options = 0)

, . / PyQt5 !

+1

All Articles