PyQt is a set of Python bindings for The Qt Toolkit library. The Qt toolkit is a C++ framework that is primarily used for creating graphical user interfaces (GUIs). It supports different platforms, such as Microsoft Windows, Mac OS and Linux.
The Python programming language provides an ideal and easy to learn scripting language for developing graphical user interfaces with PyQt. The bindings provide a high level interface between Python and Qt.
PyQt allows Python programmers to create programs with a robust, highly functional graphical user interface, simply and easily. It is also suitable for applications requiring "quick-and-dirty" GUI prototyping.
PyQt Hello World
"Hello World" is a typical example program for demonstration purposes.
This is a basic "hello world" application using the PyQt toolkit. It should give you an idea of what the PyQt framework is like.
# load pyqt widgets
from PyQt5.QtWidgets import *
import sys
class Window(QMainWindow):
def __init__(self):
super().__init__()
# the window title
self.setWindowTitle("hello dev!")
# window size
self.setGeometry(0, 0, 200, 200)
# create label
self.label = QLabel("Hello World", self)
# show all the widgets
self.show()
# create the app
App = QApplication(sys.argv)
# create Window
window = Window()
# start
sys.exit(App.exec())
To run the application, just type "python hello.py". This will open a window with the "Hello World" text.
The window properties are set in the class
# the window title
self.setWindowTitle("hello dev!")
# window size
self.setGeometry(0, 0, 200, 200)
Besides labels, you can add many things to the window like buttons, tables, select boxes, checkbox, video widgets and much much more. If you are new to PyQt, I recommend this course
Top comments (0)