DEV Community

Cover image for GUI Programming in Python
jones268
jones268

Posted on

GUI Programming in Python

PyQt is the Python binding of the cross-platform GUI toolkit Qt, written in C++. It's a library for developing cross-platform GUI applications.

There are two main ways that applications can create a GUI in Python 😄. One way is using the tkinter module , which is included with Python by default and works on both Windows and Unix-like operating systems.

The other method is using a third-party GUI library, such as Qt , wxPython or PyGTK .

Developing programs with a Graphical User Interface in Python requires the use of an appropriate toolkit. The most popular and mature framework on Python is Qt.

If you are new to PyQt, I recommend this course:
Create Desktop Apps with Python PyQt5

In my opinion, PyQt is the best way to make GUI apps with Python. Tkinter is very minimal in terms of widgets.

Why PyQt?

Qt is powerful, mature, and easy to learn. PyQt, the Python binding of Qt, gives Python programmers access to hundreds of ready-made user interface components, without forcing them to learn C++.

Using Python instead of C++ means that you can write GUI applications without having to know all the ins and outs of Qt and its class hierarchy. It also allows you to quickly create bindings for libraries like NumPy and SciPy.

pyqt widgets

Besides the widgets shown here, there are many more. There's even a video widget

PyQt is a very complete port of the Qt library, and supports all of its features: QGraphicsView, Quick, QML, and many widgets. The library has everything necessary to build complete user interfaces and programs in Python.

On top of that, you can design your GUI with drag-and-drop using Designer and Creator.

qtcreator

Qt Designer is a cross-platform WYSIWYG GUI editor based on Qt. Qt designer allows you to connect a UI to your code by dragging and dropping widgets around your form and then connecting up signals and slots.

To do that with designer you:

  • Create a UI in Qt Designer
  • Load it into Python
  • Then connect it up using the PyQt5 code

Top comments (0)