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 toolkit Qt, implemented as a Python
plug-in Plug-in, plug in or plugin may refer to: * Plug-in (computing) is a software component that adds a specific feature to an existing computer program. ** Audio plug-in, adds audio signal processing features ** Photoshop plugin, a piece of softwar ...
. 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, ...
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 user In product development, an end user (sometimes end-user) is a person who ultimately uses or is intended to ulti ...
(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 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, a ...
, 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 i ...
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 di ...
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 spa ...
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. A ...
,
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 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 wor ...
,
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 Scintilla (the Italian and Latin word for spark) may refer to: *Scintilla AG, a Swiss electrical engineering company, a 100 percent subsidiary of Robert Bosch GmbH since 2005 * Scintilla (comics), a fictional character in the Marvel Universe *S ...
-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. ...
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 sinc ...
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 telecommunications, information technology, and consumer electronics corporation, established in 1865. Nokia's main headquarters are in Espoo, Finlan ...
sought for the Python binding to be available under the LGPL 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'' (T ...
, the developer of QT. After failing to reach an agreement with Riverbank Computing, Nokia released their own binding,
PySide PySide is a Python (programming language), Python Language binding, binding of the cross-platform Graphical user interface, GUI toolkit Qt (framework), Qt developed by The Qt Company, as part of the Qt for Python project. It is one of the List of w ...
, 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 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" o ...
, 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 ha ...
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 mechanical ...
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 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 Anki may refer to: * Anki (software), spaced repetition software * Anki (company), a now-defunct American robotics and artificial intelligence startup * Anki (Finnish company), a manufacturer of rugs * Anxi County () is a county of the prefec ...
, 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 matc ...
, 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 software. Dropbox was founded in 2 ...
, a file hosting service *
Eric Python IDE eric is a 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 code and for the professional management of a software ...
* 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- ...
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 Leo or Léo may refer to: Acronyms * Law enforcement officer * Law enforcement organisation * ''Louisville Eccentric Observer'', a free weekly newspaper in Louisville, Kentucky * Michigan Department of Labor and Economic Opportunity Arts an ...
, an outliner and literate programming editor * Ninja-IDE, an extensible open-source Python IDE * OpenLP, an open-source lyrics projection program * OpenShot, 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, 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 qutebrowser (pronounced "cute browser" ) is a Chromium-based web browser for Linux, Windows, and macOS operating systems with Vim-style key bindings and a minimal GUI. It is keyboard-driven and is inspired by similar software such as Vimpe ...
, 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 an ...
, 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 client ...
, a graphical interface for the Mercurial source management program (Hg) *
Veusz Veusz is a scientific plotting package. Veusz is a Qt application written in Python, PyQt and NumPy. It is freely available for anyone to distribute under the terms of the GPL. It is designed to produce publication-quality plots. The name sh ...
, 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 or ...
(Python wrappers for GTK) *
PySide PySide is a Python (programming language), Python Language binding, binding of the cross-platform Graphical user interface, GUI toolkit Qt (framework), Qt developed by The Qt Company, as part of the Qt for Python project. It is one of the List of w ...
(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 extension ...
(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