HOME

TheInfoList



OR:

PyQt is a Python binding of the
cross-platform In computing, cross-platform software (also called multi-platform software, platform-agnostic software, or platform-independent software) is computer software that is designed to work in several computing platforms. Some cross-platform software ...
GUI The GUI ( "UI" by itself is still usually pronounced . or ), graphical user interface, is a form of user interface that allows users to interact with electronic devices through graphical icons and audio indicator such as primary notation, inste ...
toolkit Qt, implemented as a Python plug-in. PyQt is
free software Free software or libre software is computer software distributed under terms that allow users to run the software for any purpose as well as to study, change, and distribute it and any adapted versions. Free software is a matter of liberty, n ...
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 The GNU General Public License (GNU GPL or simply GPL) is a series of widely used free software licenses that guarantee end users the four freedoms to run, study, share, and modify the software. The license was the first copyleft for general ...
(GPL) and commercial license, but not the
GNU Lesser General Public License The GNU Lesser General Public License (LGPL) is a free-software license published by the Free Software Foundation (FSF). The license allows developers and companies to use and integrate a software component released under the LGPL into their own ...
(LGPL). PyQt supports
Microsoft Windows Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for ...
as well as various flavours of
UNIX Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, ...
, including
Linux Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, whi ...
and MacOS (or Darwin). PyQt implements around 440 classes and over 6,000 functions and methods including: * a substantial set of
GUI widget A graphical widget (also graphical control element or control) in a graphical user interface is an element of interaction, such as a button or a scroll bar. Controls are software components that a computer user interacts with through dir ...
s * classes for accessing SQL
database In computing, a database is an organized collection of data stored and accessed electronically. Small databases can be stored on a file system, while large databases are hosted on computer clusters or cloud storage. The design of databases ...
s (
ODBC In computing, Open Database Connectivity (ODBC) is a standard application programming interface (API) for accessing database management systems (DBMS). The designers of ODBC aimed to make it independent of database systems and operating systems. An ...
,
MySQL MySQL () is an open-source relational database management system (RDBMS). Its name is a combination of "My", the name of co-founder Michael Widenius's daughter My, and "SQL", the acronym for Structured Query Language. A relational database ...
,
PostgreSQL PostgreSQL (, ), also known as Postgres, is a free and open-source relational database management system (RDBMS) emphasizing extensibility and SQL compliance. It was originally named POSTGRES, referring to its origins as a successor to the ...
,
Oracle An oracle is a person or agency considered to provide wise and insightful counsel or prophetic predictions, most notably including precognition of the future, inspired by deities. As such, it is a form of divination. Description The word ...
,
SQLite SQLite (, ) is a database engine written in the C programming language. It is not a standalone app; rather, it is a library that software developers embed in their apps. As such, it belongs to the family of embedded databases. It is the mo ...
) * QScintilla, Scintilla-based rich text editor widget * data aware widgets that are automatically populated from a database * an
XML Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. T ...
parser *
SVG Scalable Vector Graphics (SVG) is an XML-based vector image format for defining two-dimensional graphics, having support for interactivity and animation. The SVG specification is an open standard developed by the World Wide Web Consortium s ...
support * classes for embedding
ActiveX ActiveX is a deprecated software framework created by Microsoft that adapts its earlier Component Object Model (COM) and Object Linking and Embedding (OLE) technologies for content downloaded from a network, particularly from the World Wide We ...
controls on Windows (only in commercial version) 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 Nokia Corporation (natively Nokia Oyj, referred to as Nokia) is a Finnish multinational telecommunications, information technology, and consumer electronics corporation, established in 1865. Nokia's main headquarters are in Espoo, Finland, i ...
sought for the Python binding to be available under the
LGPL The GNU Lesser General Public License (LGPL) is a free-software license published by the Free Software Foundation (FSF). The license allows developers and companies to use and integrate a software component released under the LGPL into their own ...
license. At the time, Nokia owned Qt Software, the developer of QT. After failing to reach an agreement with Riverbank Computing, Nokia released their own binding, PySide, providing similar functionality.


Main components

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 Unicode, formally The Unicode Standard,The formal version reference is is an information technology standard for the consistent encoding, representation, and handling of text expressed in most of the world's writing systems. The standard, ...
, 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 Model–view–controller (MVC) is a software architectural pattern commonly used for developing user interfaces that divide the related program logic into three interconnected elements. This is done to separate internal representations of info ...
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 The Hypertext Transfer Protocol (HTTP) is an application layer protocol in the Internet protocol suite model for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide We ...
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 OpenGL (Open Graphics Library) is a cross-language, cross-platform application programming interface (API) for rendering 2D and 3D vector graphics. The API is typically used to interact with a graphics processing unit (GPU), to achieve hardwa ...
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 SQLite (, ) is a database engine written in the C programming language. It is not a standalone app; rather, it is a library that software developers embed in their apps. As such, it belongs to the family of embedded databases. It is the mo ...
. * 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 In physics, a phonon is a collective excitation in a periodic, elastic arrangement of atoms or molecules in condensed matter, specifically in solids and some liquids. A type of quasiparticle, a phonon is an excited state in the quantum mechani ...
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 The latest version of Qt is 6.5 released on 3 April 2023. Also still supported, for commercial users, are 5.15 LTS, released on 26 May 2020, and 6.2 LTS, released on 30 September 2021 – long-term support (LTS) versions are generally supported f ...
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 shows a small window on the screen.


PyQt4

#! /usr/bin/env python3 # Character Encoding: UTF-8 # # Here we provide the necessary imports. # The basic GUI widgets are located in QtGui module. import sys from PyQt4.QtGui import QApplication, QWidget # Every PyQt4 application must create an application object. # The application object is located in the QtGui module. app = QApplication(sys.argv) # The QWidget widget is the base class of all user interface objects in PyQt4. # 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.


PyQt5

#! /usr/bin/env python3 # Character Encoding: UTF-8 # # Here we provide the necessary imports. # The basic GUI widgets are located in QtWidgets module. import sys from PyQt5.QtWidgets import QApplication, QWidget # Every PyQt5 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 PyQt5. # 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.


PyQt6

#! /usr/bin/env python3 # Character Encoding: UTF-8 # # Here we provide the necessary imports. # The basic GUI widgets are located in QtWidgets module. import sys from PyQt6.QtWidgets import QApplication, QWidget # Every PyQt6 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 PyQt6. # 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

* Anki, a spaced repetition flashcard program * Calibre, an E-book management application * Dropbox, a file hosting service * Eric Python IDE * fman, a cross-platform file manager *
Frescobaldi The Frescobaldi are a prominent Florentine noble family that have been involved in the political, social, and economic history of Tuscany since the Middle Ages. Originating in the Val di Pesa in the Chianti, they appear holding important post ...
, a score editor for
LilyPond LilyPond is a computer program and file format for music engraving. One of LilyPond's major goals is to produce scores that are engraved with traditional layout rules, reflecting the era when scores were engraved by hand. LilyPond is cross-pla ...
music files * Kodos, a Python
Regular expression A regular expression (shortened as regex or regexp; sometimes referred to as rational expression) is a sequence of characters that specifies a search pattern in text. Usually such patterns are used by string-searching algorithms for "find" ...
Debugger * Leo, an outliner and literate programming editor *
Ninja-IDE NINJA-IDE (from the recursive acronym: "Ninja-IDE Is Not Just Another IDE"), is a cross-platform integrated development environment (IDE) designed to build Python applications. It provides tools to simplify Python software development and handles ...
, an extensible open-source Python IDE * OpenLP, an open-source lyrics projection program *
OpenShot OpenShot Video Editor is a free and open-source video editor for Windows, macOS, Linux, and ChromeOS. The project started in August 2008 by Jonathan Thomas, with the objective of providing a stable, free, and friendly to use video editor. The pr ...
, a video editing program * Orange, a data mining and visualization framework * Puddletag, an open-source, cross-platform ID3 tag editor *
QGIS QGIS is a free and open-source cross-platform desktop geographic information system (GIS) application that supports viewing, editing, printing, and analysis of geospatial data. Functionality QGIS functions as geographic information system (GIS) ...
, a free software desktop Geographic Information Systems (GIS) application * qutebrowser, a web browser with Vim-style key bindings and a minimal GUI. * qt-recordMyDesktop, a Qt4 frontend for recordMyDesktop * Spyder, a Python data science IDE *
TortoiseHg __NOTOC__ TortoiseHg is a GUI front-end for Mercurial that runs on Microsoft Windows (on which it integrates directly with File Explorer), Mac OS X, and Linux. It is written in PyQt (except the Windows shell extension), and the underlying c ...
, a graphical interface for the Mercurial source management program (Hg) * Veusz, a scientific plotting application *
GNS3 Graphical Network Simulator-3 (shortened to GNS3) is a network software emulator first released in 2008. It allows the combination of virtual and real devices, used to simulate complex networks. It uses Dynamips emulation software to simulate ...
, a network software emulator


See also

*
PyGTK PyGTK is a set of Python wrappers for the GTK graphical user interface library. PyGTK is free software and licensed under the LGPL. It is analogous to PyQt/ PySide and wxPython, the Python wrappers for Qt and wxWidgets, respectively. Its ...
(Python wrappers for GTK) * PySide (Alternative Python wrapper for the Qt toolkit) *
wxPython wxPython is a wrapper for the cross-platform GUI API (often referred to as a "toolkit") wxWidgets (which is written in C++) for the Python programming language. It is one of the alternatives to Tkinter. It is implemented as a Python extensio ...
(Python wrapper for the wx widgets collection) * Kivy * Tkinter (bundled with Python)


References


Further reading

* * *


External links

*
PyQt and PyKDE community Wiki

PyQt6 Tutorial Series

PyQt5 Tutorial Series

PyQT4 tutorial series

Tutorials

Tutorial
{{DEFAULTSORT:Pyqt Articles with example Python (programming language) code Cross-platform free software Free computer libraries Free software programmed in C++ Free software programmed in Python Python (programming language) libraries Qt (software) Widget toolkits