HOME

TheInfoList



OR:

PyQt is a Python binding of the
cross-platform Within 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 platform, computing platforms. Some ...
GUI toolkit Qt, implemented as a Python plug-in. PyQt is
free software Free software, libre software, libreware sometimes known as freedom-respecting software is computer software distributed open-source license, under terms that allow users to run the software for any purpose as well as to study, change, distribut ...
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. * British national identity, the characteristics of British people and culture ...
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 Licenses (GNU GPL or simply GPL) are a series of widely used free software licenses, or ''copyleft'' licenses, that guarantee end users the freedom to run, study, share, or modify the software. The GPL was the first ...
(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 Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
as well as various kinds of
UNIX Unix (, ; trademarked as UNIX) is a family of multitasking, multi-user 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 ( ) is a family of open source Unix-like operating systems based on the Linux kernel, an kernel (operating system), operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically package manager, pac ...
and
macOS macOS, previously OS X and originally Mac OS X, is a Unix, Unix-based operating system developed and marketed by Apple Inc., Apple since 2001. It is the current operating system for Apple's Mac (computer), Mac computers. With ...
. 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 m ...
s * classes for accessing SQL
database In computing, a database is an organized collection of data or a type of data store based on the use of a database management system (DBMS), the software that interacts with end users, applications, and the database itself to capture and a ...
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 software, 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 rel ...
,
PostgreSQL PostgreSQL ( ) also known as Postgres, is a free and open-source software, free and open-source relational database management system (RDBMS) emphasizing extensibility and SQL compliance. PostgreSQL features transaction processing, transactions ...
,
Oracle An oracle is a person or thing considered to provide insight, wise counsel or prophetic predictions, most notably including precognition of the future, inspired by deities. If done through occultic means, it is a form of divination. Descript ...
, SQLite) * 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 data. It defines a set of rules for encoding electronic document, documents in a format that is both human-readable and Machine-r ...
parser Parsing, syntax analysis, or syntactic analysis is a process of analyzing a string of symbols, either in natural language, computer languages or data structures, conforming to the rules of a formal grammar by breaking it into parts. The term '' ...
* 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 W ...
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 is a Finnish multinational corporation, multinational telecommunications industry, telecommunications, technology company, information technology, and consumer electronics corporation, originally established as a pulp mill in 1 ...
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 its 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 or ''The Unicode Standard'' or TUS is a character encoding standard maintained by the Unicode Consortium designed to support the use of text in all of the world's writing systems that can be digitized. Version 16.0 defines 154,998 Char ...
, 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 character (computing), characters that specifies a pattern matching, match pattern in string (computer science), text. Usually ...
, 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 divides the related program logic into three interconnected elements. These elements are: * the model, the internal representat ...
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 dat ...
and
HTTP HTTP (Hypertext Transfer Protocol) 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, wher ...
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 Language-independent specification, cross-language, cross-platform application programming interface (API) for rendering 2D computer graphics, 2D and 3D computer graphics, 3D vector graphics. The API is typic ...
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 A phonon is a collective excitation in a periodic, elastic arrangement of atoms or molecules in condensed matter, specifically in solids and some liquids. In the context of optically trapped objects, the quantized vibration mode can be defined a ...
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 * QtQuick 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

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

* Anki, a spaced repetition flashcard program * Calibre, an E-book management application *
Dropbox Dropbox is a file hosting service operated by the American company Dropbox, Inc., headquartered in San Francisco, California, that offers cloud storage, file synchronization, personal cloud, and Client (computing), client software. Dropbox w ...
, a file hosting service
EarQuiz Frequencies
a free and open-source application for EQ/frequency ear training * Electrum Bitcoin Wallet * Eric Python IDE * Frescobaldi, 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 match pattern in text. Usually such patterns are used by string-searching algorithms for "find" ...
Debugger * Leo, 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, a data mining and visualization framework * Puddletag, an open-source, cross-platform ID3 tag editor *
QGIS QGIS is a geographic information system (GIS) software that is free and open-source. QGIS supports Windows, macOS, and Linux. It supports viewing, editing, printing, and analysis of geospatial data in a range of data formats. Its name comes from ...
, 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, a graphical interface for the Mercurial source management program (Hg) * Veusz, a scientific plotting application * GNS3, a network software emulator


See also

*
PyGTK PyGTK is a set of Python (programming language), Python Adapter pattern, wrappers for the GTK graphical user interface library (computer science), library. PyGTK is free software and licensed under the LGPL. It is analogous to PyQt/PySide and w ...
(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

* * *


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