Pyqt

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). PyQt supports Microsoft Windows as well as various kinds of UNIX, including Linux and MacOS (or Darwin).

PyQt
Developer(s)Riverbank Computing
Initial release1998
Stable release
6.6.1 Edit this on Wikidata / 4 December 2023; 4 months ago (4 December 2023)
Written inC++ / Python
Operating systemCross-platform
LicenseGNU GPL and commercial
Websiteriverbankcomputing.com

PyQt implements around 440 classes and over 6,000 functions and methods 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.

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.

Main components

Pyqt 
Alternative PyQt logo

PyQt4 contains the following Python modules.

  • The QtCore module contains the core non-GUI classes, including the event loop and Qt's signal and slot mechanism. It also includes platform independent abstractions for Unicode, threads, mapped files, shared memory, regular expressions, and user and application settings.
  • The QtGui module contains the majority of the GUI classes. These include a number of table, tree and list classes based on the model–view–controller design pattern. Also provided is a sophisticated 2D canvas widget capable of storing thousands of items including ordinary widgets.
  • The QtNetwork module contains classes for writing UDP and TCP clients and servers. It includes classes that implement FTP and HTTP clients and support DNS lookups. Network events are integrated with the event loop making it very easy to develop networked applications.
  • The QtOpenGL module contains classes that enable the use of OpenGL in rendering 3D graphics in PyQt applications.
  • The QtSql module contains classes that integrate with open-source and proprietary SQL databases. It includes editable data models for database tables that can be used with GUI classes. It also includes an implementation of SQLite.
  • The QtSvg module contains classes for displaying the contents of SVG files. It supports the static features of SVG 1.2 Tiny.
  • The QtXml module implements SAX and DOM interfaces to Qt's XML parser.
  • The QtMultimedia module implements low-level multimedia functionality. Application developers would normally use the phonon module.
  • The QtDesigner module contains classes that allow Qt Designer to be extended using PyQt.
  • The Qt module consolidates the classes contained in all of the modules described above into a single module. This has the advantage that you don't have to worry about which underlying module contains a particular class. It has the disadvantage that it loads the whole of the Qt framework, thereby increasing the memory footprint of an application. Whether you use this consolidated module, or the individual component modules is down to personal taste.
  • The uic module implements support for handling the XML files created by Qt Designer that describe the whole or part of a graphical user interface. It includes classes that load an XML file and render it directly, and classes that generate Python code from an XML file for later execution.

PyQt5 contains the following Python modules:

  • QtQml Module
  • QtQtuick Module
  • QtCore Module
  • QtGui Module
  • QtPrintSupport Module
  • QtWidgets Module
  • QGLContext Module
  • QGLFormat Module
  • QGLWidget Module
  • QtWebKit Module
  • QtWebKitWidgets Module

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

Pyqt 
The result in KDE Plasma 4

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

#!/usr/bin/env python3 """ Here we provide the necessary imports. The basic GUI widgets are located in QtWidgets module. """ import sys from PyQt6.QtWidgets import QApplication, QWidget  # Every PyQt application must create an application object. # The application object is located in the QtWidgets module. app = QApplication([])  # The QWidget widget is the base class of all user interface objects in PyQt. # We provide the default constructor for QWidget. The default constructor has no parent. # 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

  • PyGTK (Python wrappers for GTK)
  • PySide (Alternative Python wrapper for the Qt toolkit)
  • wxPython (Python wrapper for the wx widgets collection)
  • Kivy
  • Tkinter (bundled with Python)

References

Further reading

Tags:

Pyqt HistoryPyqt Main componentsPyqt VersionsPyqt Hello World examplePyqt Notable applications that use PyQtPyqt Further readingPyqtCross-platformFree softwareGNU General Public LicenseGNU Lesser General Public LicenseGUILanguage bindingLinuxMacOSMicrosoft WindowsPlug-in (computing)Python (programming language)Qt (toolkit)United KingdomUnix

🔥 Trending searches on Wiki English:

Arne SlotQueen VictoriaCaitlyn JennerManchester United F.C.Jim Henson2024 Indian general election in Uttar PradeshGeorge SorosJulius CaesarTony KhanArgylleCillian MurphyAnimal (2023 Indian film)United StatesThe Goat LifeKorean WarOpinion polling for the next United Kingdom general electionOperation Mongoose2022 NFL draftShahid KhanDune (2021 film)Darrell GreenKingdom of the Planet of the Apes2019 Indian general electionBlackpinkHyderabad Lok Sabha constituencyBeyoncéInvincible (TV series)Sachin TendulkarSonia SotomayorMatthew PerryUtsuro-buneUnited KingdomRoad House (2024 film)Queen of TearsArtificial intelligenceBrad PittErik SpoelstraWikipediaMatty HealyKendrick LamarMinouche ShafikStephen CurryGoogle TranslateDwight D. EisenhowerThe Moody BluesTrap (2024 film)X (2022 film)Game of ThronesIvy LeagueWorld Wide WebTravis KelceNelson MandelaAriana GrandeOrlando BloomRobert KraftJames ClavellAnthony Edwards (basketball)2020 NFL draftMin Hee-jinReal Madrid CFList of country calling codesSnapchatMarc-André LeclercArmeniaIndiaUEFA Champions LeagueDead Boy DetectivesSylvester StalloneJessica GunningAngelina JolieKate HudsonMount TakaheThe Analytical Language of John WilkinsGermanyGitHubThe Amazing Race 36🡆 More