Python3 PyQT4 Advises?

Hi

I am discovering Python3, written already a first tool with it and now “simply” want to make a GUI for it.

I have so start looking at pyQT, (pyQT4, I didn’t found any references for pyQT5, only C++ ones, no python.).

And I am struggling a bit for finding tutorials about pyQT4 in python3. They are often with python2.7 or using QTdesigner which is great but so limited I don’t understand how it can be useful (no spinners, no browser query and I don’t even thin how to make dynamic gui with that…)… But tutorials, or simple exemples about GUI scripting only with pyQT4, no QTdesigner, niet, nada.
I’d like to code my UI entirely in my IDE, in python3, just as I was doing with maxscript.
BUT, I can’t find simple sample, the ones I found are quite indigestible with bits of code all over the place and no coments anywhere explaining what does what.
I wonder if it is possible to have a layout similar to what I could do in MaxScript like :

a/ Declare my Rollout 
b/ Declare my buttons (with groups and all which could be the same with the layout I can see in pyQT)

c/ Events

d/ Create dialog

the end.

And here’s a very very simple python code generated from QtDesigner (One button in one layout, that’s its.) :

from PyQt4 import QtCore, QtGui

try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    def _fromUtf8(s):
        return s

try:
    _encoding = QtGui.QApplication.UnicodeUTF8
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig)

class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName(_fromUtf8("Form"))
        Form.resize(400, 299)
        self.horizontalLayout = QtGui.QHBoxLayout(Form)
        self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
        self.verticalLayout = QtGui.QVBoxLayout()
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.btn_TestButton001 = QtGui.QPushButton(Form)
        self.btn_TestButton001.setObjectName(_fromUtf8("btn_TestButton001"))
        self.verticalLayout.addWidget(self.btn_TestButton001)
        self.horizontalLayout.addLayout(self.verticalLayout)

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        Form.setWindowTitle(_translate("Form", "Image Cutter", None))
        self.btn_TestButton001.setText(_translate("Form", "TestButton001", None))


if __name__ == '__main__':

    import sys

    app = QtGui.QApplication(sys.argv)
    window = Window()
    window.show()
    sys.exit(app.exec_())


Which is quite a mess to me and not readable (though I don’t have a problem reading code in general, but this one looks very filthy to me).
And now I wonder if it is : 1) because of the conversion from QTdesigner or 2) if it is a standard writing for a pyQT4 script.

In the first case if someone could point me to some properly written pyQT script (with nice coments and all) that would be great.
In the second case if someone could point me to some tutorial or samples with coments explaining this code that would save my day.

Or maybe it is simply best not coding in python and using a solution like QML ? In any case any advise is most welcom.

Many Thanks
Bloby

Nobody uses Python3 yet. Too much legacy pipeline code. Just use Python2.7. It’s perfectly adequate.

Hum here it’s more pyQT than Python3 or 2.7 my issue. If I could get good exemple in python2.7 it will be just as fine to me as they look pretty similar, I could always translate. Py3 do not really block me so far, it’s all working and I get the modules I need.
Even this pyQT4 is working all good, I just can’t find references, pretty samples, of it, weither it’s py2.7 or py3 to understand how to use it.
I plan to go on py2.7 once this tool is finish anyway, from what I have seen there is much more modules in 2.7 than 3 which can make a huge difference when it comes to bigger project. Besides, most 3d/animation softwares use the 2.7.
But well, I want to finish first this tool in py3, there’s nothing wrong with it for my little need. Once I’ll know how pyQT works that will be just as good in 3 or 2.7. 2.7 is still much more used, but I know also for sure 3 start to be use seriously here and there, always good to know both.

http://zetcode.com/gui/pyqt4/firstprograms/ this looks rather nice. Can’t believe I didnt saw it earlier.

http://www.youcandoitvfx.com/python-versions-in-cg-software/

And btw, go with PySide instead.

Joy I am not using python for cg software. :slight_smile: But this is not a python 2.7/3 thread. It’s a pyQT one.

I have read here and there pyside was pretty much the exact same than pyQT. The only main difference is the less restrictive licence. Any other advantages with PySide I am not aware of?

take a look this one http://zetcode.com/gui/pyqt4/, it’s good enough for beginning

Thanks Styler, I just found it too. This tuto is perfect, exactly what I was looking for.