HOME

TheInfoList



OR:

PyQt is a
Python Python may refer to: Snakes * Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia ** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia * Python (mythology), a mythical serpent Computing * Python (pro ...
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 r ...
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, no ...
developed by the
British British may refer to: Peoples, culture, and language * British people, nationals or natives of the United Kingdom, British Overseas Territories, and Crown Dependencies. ** Britishness, the British identity and common culture * British English, ...
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 (Free software), four freedoms to run, study, share, and modify the software. The license was th ...
(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 serv ...
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, and ot ...
, 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, which ...
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 direct ...
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 sp ...
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 o ...
,
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 In ...
,
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 most ...
) * 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 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 Web. ...
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 corporation, multinational telecommunications industry, telecommunications, technology company, information technology, and consumer electronics corporatio ...
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 QT or Qt may refer to: Arts and media * QT (musician) (born 1988), pop singer * ''QT: QueerTelevision'', an LGBT newsmagazine which aired on Canada's CityTV in the 1990s * Quentin Tarantino (born 1963), American filmmaker * Question Time (TV prog ...
, the developer of QT. After failing to reach an agreement with Riverbank Computing, Nokia released their own binding,
PySide PySide is a Python binding of the cross-platform GUI toolkit Qt developed by The Qt Company, as part of the Qt for Python project. It is one of the alternatives to the standard library package Tkinter. Like Qt, PySide is free software. PySide sup ...
, 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 Technical standard, standard for the consistent character encoding, encoding, representation, and handling of Character (computing), text expre ...
, threads, mapped files, shared memory,
regular expressions 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" or ...
, 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 infor ...
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 The File Transfer Protocol (FTP) is a standard communication protocol used for the transfer of computer files from a server to a client on a computer network. FTP is built on a client–server model architecture using separate control and data ...
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 Web, ...
clients and support
DNS The Domain Name System (DNS) is a hierarchical and distributed naming system for computers, services, and other resources in the Internet or other Internet Protocol (IP) networks. It associates various information with domain names assigned to ...
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 most ...
. * 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 Dom or DOM may refer to: People and fictional characters * Dom (given name), including fictional characters * Dom (surname) * Dom La Nena (born 1989), stage name of Brazilian-born cellist, singer and songwriter Dominique Pinto * Dom people, an et ...
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, Elasticity (physics), elastic arrangement of atoms or molecules in condensed matter physics, condensed matter, specifically in solids and some liquids. A type of quasiparticle, a phon ...
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 Qt (pronounced "cute") is cross-platform software for creating graphical user interfaces as well as cross-platform applications that run on various software and hardware platforms such as Linux, Windows, macOS, Android or embedded systems wit ...
. 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 In guns, particularly firearms, caliber (or calibre; sometimes abbreviated as "cal") is the specified nominal internal diameter of the gun barrel bore – regardless of how or where the bore is measured and whether the finished bore match ...
, an E-book management application *
Dropbox Dropbox is a file hosting service operated by the American company Dropbox, Inc., headquartered in San Francisco, California, U.S. that offers cloud storage, file synchronization, personal cloud, and Client (computing), client software. Dropb ...
, a file hosting service *
Eric Python IDE eric is a Free Software, free integrated development environment (IDE) used for computer programming. Since it is a full featured IDE, it provides by default all necessary tools needed for the writing of Source code, code and for the professional ...
* 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 posts ...
, 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-pl ...
music files * Kodos, a
Python Python may refer to: Snakes * Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia ** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia * Python (mythology), a mythical serpent Computing * Python (pro ...
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" or ...
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 Python may refer to: Snakes * Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia ** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia * Python (mythology), a mythical serpent Computing * Python (pro ...
IDE *
OpenLP OpenLP is a worship presentation program licensed under the GNU General Public License version 2. It includes the ability to search through lyrics for certain words, search for Bible verses in the Bible, display lyrics and Bible verses in a friend ...
, 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 Orange most often refers to: *Orange (fruit), the fruit of the tree species '' Citrus'' × ''sinensis'' ** Orange blossom, its fragrant flower *Orange (colour), from the color of an orange, occurs between red and yellow in the visible spectrum * ...
, a data mining and visualization framework *
Puddletag Puddletag is a graphical audio file metadata editor ("tagger") for Unix-like operating systems. It is free and open-source software subject to the terms of the GNU General Public License (GPL) version 3. In most major desktop Linux distributions, ...
, 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 The SPYDER ("Surface-to-air Python and Derby") is an Israeli short and medium range mobile air defence system developed by Rafael Advanced Defense Systems with assistance from Israel Aerospace Industries (IAI). Rafael is the prime contractor a ...
, a
Python Python may refer to: Snakes * Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia ** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia * Python (mythology), a mythical serpent Computing * Python (pro ...
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 client ...
, a graphical interface for the Mercurial source management program (Hg) *
Veusz Veusz is a scientific plotting package. Veusz is a Qt (software), Qt application written in Python (programming language), Python, PyQt and NumPy. It is Free software, freely available for anyone to distribute under the terms of the GNU General ...
, a scientific plotting application *
GNS3 Graphical Network Simulator-3 (shortened to GNS3) is a Computer network, 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 soft ...
, 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 PySide is a Python binding of the cross-platform GUI toolkit Qt developed by The Qt Company, as part of the Qt for Python project. It is one of the alternatives to the standard library package Tkinter. Like Qt, PySide is free software. PySide sup ...
(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 Tkinter is a Python binding to the Tk GUI toolkit. It is the standard Python interface to the Tk GUI toolkit, and is Python's ''de facto'' standard GUI. Tkinter is included with standard Linux, Microsoft Windows and macOS installs of Python. T ...
(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