PyQt explained

Logo Size:160px
Screenshot Size:300px
Developer:Riverbank Computing
Released:1998
Operating System:Cross-platform
Programming Language:C++ / Python[1]
License:GNU GPL and commercial
Website:riverbankcomputing.com

PyQt is a Python binding of the cross-platform GUI toolkit Qt, implemented as a Python plug-in. PyQt is free software developed by the British firm Riverbank Computing. It is available under similar terms to Qt versions older than 4.5; this means a variety of licenses including GNU General Public License (GPL) and commercial license, but not the GNU Lesser General Public License (LGPL).[2] PyQt supports Microsoft Windows as well as various kinds of UNIX, including Linux and MacOS (or Darwin).[3]

PyQt implements around 440 classes and over 6,000 functions and methods[4] including:

To automatically generate these bindings, Phil Thompson developed the tool SIP, which is also used in other projects.

History

PyQt was first released by Riverbank Computing in 1998.[7]

In August 2009, Nokia sought for the Python binding to be available under the LGPL license. At the time, Nokia owned Qt Software, the developer of QT. After failing to reach an agreement with Riverbank Computing, Nokia released its binding, PySide, providing similar functionality.[8]

Main components

PyQt4 contains the following Python modules.

PyQt5 contains the following Python modules:

Versions

PyQt version 4 works with both Qt 4 and Qt 5. PyQt version 5 only supports Qt version 5, and drops support for features that are deprecated in Qt 5.

Hello World example

The below code written for PyQt6 shows a small window on the screen.

  1. !/usr/bin/env python3

"""Here we provide the necessary imports.The basic GUI widgets are located in QtWidgets module."""import sysfrom PyQt6.QtWidgets import QApplication, QWidget

  1. Every PyQt application must create an application object.
  2. The application object is located in the QtWidgets module.

app = QApplication([])

  1. The QWidget widget is the base class of all user interface objects in PyQt.
  2. We provide the default constructor for QWidget. The default constructor has no parent.
  3. A widget with no parent is called a window.

root = QWidget

root.resize(320, 240) # The resize method resizes the widget.root.setWindowTitle("Hello, World!") # Here we set the title for our window.root.show # The show method displays the widget on the screen.

sys.exit(app.exec) # Finally, we enter the mainloop of the application.

Notable applications that use PyQt

See also

External links

Notes and References

  1. Web site: PyQt4 Download. Riverbankcomputing. 2010. 2010-04-19.
  2. Web site: Riverbank | Commercial | License FAQ . Riverbankcomputing.com . 2015-06-24.
  3. Web site: What is PyQt? . Riverbank Computing . 2014-09-18.
  4. Web site: PyQt v4 - Python Bindings for Qt v4 . https://web.archive.org/web/20080429185425/http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/pyqt4ref.html . dead. Riverbankcomputing . 2008-04-29 . 2010-04-17 .
  5. Web site: QSqlDatabase Class Reference . Pyqt.sourceforge.net. 2014-09-25.
  6. https://wiki.python.org/moin/PyQt PythonInfo Wiki
  7. Book: Jarmul . Katharine . Python Web Scraping . Lawson . Richard . 2017-05-30 . Packt Publishing Ltd . 978-1-78646-429-3 . 105 . en.
  8. Web site: faq . Martin Fitzpatrick Last updated . 2019-06-21 . PyQt5 vs PySide2: What's the difference between the two Python Qt libraries? . 2022-06-25 . Python GUIs . en-us.
  9. Web site: Riverbank | Software | PyQt | What is PyQt? . Riverbankcomputing.co.uk . 2010-04-15.