The program “Hello World” with PyQT, a module for creating desktop apps. In this article you’ll learn how to create the “hello world” app in PyQt.
If you want to make a desktop app or graphical user interface, PyQT is a good module for that.
Before starting this tutorial, make sure you have PyQt5 installed.
PyQt Desktop Apps with Python
The program below creates the “hello world” window.
PyQT is initialized with the code below:
app = QApplication(sys.argv)
Text cannot be added immediately to a window. It has to be added to a label.
A label is a widget that can show text or images. These lines create a QLabel, set the labels text and position (horizontal, vertical).
textLabel = QLabel(widget)
Now you should show the window.
Set the starting position (50,50) and the window size (320,200) with the method setGeometry().
Then you want to show the window! Give it a title with setWindowTitle() and display it with show().