DEV Community

threadspeed
threadspeed

Posted on

Is PYQT hard to use for Python beginners?

No, it's quite user-friendly after you learned the Python basics. PyQt is a GUI module for Python.

There is lots of material to learn Pyqt, like this book or howto.

Unlike other GUI modules, PyQt comes with a designer program that lets you drag and drop your GUI elements on your window. You can then export it as .ui file and load it in Python.

pyqt designer

So once you know the basics of Python, it's very easy to learn because there is a lot of training material and even a GUI designer. This makes it very easy to create desktop applications with Python.

In fact, there are many many tutorials for PyQt. Here is a short list of tutorials for creating a GUI with PyQt:

This is what the "hello world" app looks like with PyQt. If you know Python and objects/classes it's straight forward, but without knowing it can be hard to grasp.

from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout                                                                
from PyQt5.QtCore import Qt                                                                                                                

class Window(QWidget):                                                                                                                     
    def __init__(self):                                                                                                                    
        QWidget.__init__(self)                                                                                                             
        self.button = QPushButton('Hello World', self)                                                                                     
        self.button.clicked.connect(self.handleButton)                                                                                     
        layout = QVBoxLayout(self)                                                                                                         
        layout.addWidget(self.button)                                                                                                      

    def handleButton(self):                                                                                                                
        print ('Hello World')                                                                                                              

if __name__ == '__main__':                                                                                                                 
    import sys                                                                                                                             
    app = QApplication(sys.argv)                                                                                                           
    window = Window()                                                                                                                      
    window.show()                                                                                                                          
    sys.exit(app.exec_())  

Top comments (0)