Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
PyQt
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Python GUI library}} {{Infobox software | logo = Python and Qt.svg | logo size = 160px | screenshot = Screenshot-qt-designer-qwebview.png | screenshot size = 300px | caption = [[Qt Designer]] | developer = Riverbank Computing | released = 1998 | latest release version = {{wikidata|property|edit|reference|P348}} | latest release date = {{start date and age|{{wikidata|qualifier|P348|P577}}}} | latest preview version = | latest preview date = | operating system = [[Cross-platform]] | programming language = [[C++]] / [[Python (programming language)|Python]]<ref>{{cite web|url=http://www.riverbankcomputing.com/software/pyqt/download|title=PyQt4 Download|publisher=Riverbankcomputing|year=2010|access-date=2010-04-19}}</ref> | genre = | license = GNU GPL and commercial | website = [http://www.riverbankcomputing.com/software/pyqt/ riverbankcomputing.com] }} '''PyQt''' is a [[Python (programming language)|Python]] [[Language binding|binding]] of the [[cross-platform]] [[GUI]] toolkit [[Qt (toolkit)|Qt]], implemented as a Python [[Plug-in (computing)|plug-in]]. PyQt is [[free software]] developed by the [[United Kingdom|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).<ref>{{cite web|url=http://www.riverbankcomputing.com/commercial/license-faq |title=Riverbank | Commercial | License FAQ |publisher=Riverbankcomputing.com |access-date=2015-06-24}}</ref> PyQt supports [[Microsoft Windows]] as well as various kinds of [[Unix|UNIX]], including [[Linux]] and [[macOS]].<ref name="riverbankcomputing-2014">{{cite web | url=http://www.riverbankcomputing.co.uk/software/pyqt/intro | title=What is PyQt? | publisher=Riverbank Computing | access-date=2014-09-18}}</ref> PyQt implements around 440 classes and over 6,000 functions and methods<ref>{{cite web | url=http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/pyqt4ref.html#introduction | archive-url=https://web.archive.org/web/20080429185425/http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/pyqt4ref.html | url-status=dead| title=PyQt v4 - Python Bindings for Qt v4 | publisher=Riverbankcomputing | archive-date=2008-04-29 | access-date=2010-04-17 }}</ref> including: * a substantial set of [[GUI widget]]s * [[Class (computer science)|classes]] for accessing [[SQL]] [[database]]s ([[ODBC]], [[MySQL]], [[PostgreSQL]], [[Oracle database|Oracle]], [[SQLite]])<ref>{{cite web | title= QSqlDatabase Class Reference |url = http://pyqt.sourceforge.net/Docs/PyQt4/qsqldatabase.html |work=Pyqt.sourceforge.net| access-date=2014-09-25}}</ref> * QScintilla, [[Scintilla (editing component)|Scintilla]]-based rich text editor widget * data aware widgets that are automatically populated from a database * an [[XML]] [[Parsing|parser]] * [[Scalable Vector Graphics|SVG]] support * classes for embedding [[ActiveX]] controls on Windows (only in commercial version)<ref>[https://wiki.python.org/moin/PyQt PythonInfo Wiki]</ref> To automatically generate these bindings, Phil Thompson developed the tool [[SIP (software)|SIP]], which is also used in other projects. == History == PyQt was first released by Riverbank Computing in 1998.<ref>{{Cite book |last1=Jarmul |first1=Katharine |url=https://books.google.com/books?id=jHc5DwAAQBAJ&dq=pyqt+first+release&pg=PA105 |title=Python Web Scraping |last2=Lawson |first2=Richard |date=2017-05-30 |publisher=Packt Publishing Ltd |isbn=978-1-78646-429-3 |page=105 |language=en}}</ref> In August 2009, [[Nokia]] sought for the Python binding to be available under the [[GNU Lesser General Public License|LGPL]] license. At the time, Nokia owned [[The Qt Company|Qt Software]], the developer of QT. After failing to reach an agreement with Riverbank Computing, Nokia released its binding, [[PySide]], providing similar functionality.<ref>{{Cite web |last=faq |first=Martin Fitzpatrick Last updated |date=2019-06-21 |title=PyQt5 vs PySide2: What's the difference between the two Python Qt libraries? |url=https://www.pythonguis.com/faq/pyqt5-vs-pyside2/ |access-date=2022-06-25 |website=Python GUIs |language=en-us}}</ref> ==Main components== [[Image:Python and Qt 2.svg|160px|thumb|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 computer graphics|2D]] canvas widget capable of storing thousands of items including ordinary widgets. * The ''QtNetwork'' module contains classes for writing [[User Datagram Protocol|UDP]] and [[Transmission Control Protocol|TCP]] clients and servers. It includes classes that implement [[FTP]] and [[HTTP]] clients and support [[Domain Name System|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 computer graphics|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 [[Simple API for XML|SAX]] and [[Document Object Model|DOM]] interfaces to Qt's XML parser. * The ''QtMultimedia'' module implements low-level multimedia functionality. Application developers would normally use the [[Phonon (KDE)|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.<ref name="riverbankcomputing-2010">{{cite web|url=http://www.riverbankcomputing.co.uk/software/pyqt/intro |title=Riverbank | Software | PyQt | What is PyQt? |publisher=Riverbankcomputing.co.uk |access-date=2010-04-15}}</ref> 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,<ref name="riverbankcomputing-2014" /> and drops support for features that are deprecated in Qt 5.<ref>{{citation | work=PyQt 5.3.2 Reference Guide | title=Differences Between PyQt4 and PyQt5 | url=http://pyqt.sourceforge.net/Docs/PyQt5/pyqt4_differences.html | access-date=2014-09-18 | archive-date=2018-08-14 | archive-url=https://web.archive.org/web/20180814232904/http://pyqt.sourceforge.net/Docs/PyQt5/pyqt4_differences.html | url-status=dead }}</ref> ==Hello World example== [[File:PyQt screen.png|frame|right|The result in [[Plasma 4|KDE Plasma 4]]]] The below code written for PyQt6 shows a small window on the screen. <syntaxhighlight lang="python3" line="1"> #!/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. </syntaxhighlight> ==Notable applications that use PyQt== * [[Anki (software)|Anki]], a spaced repetition flashcard program * [[Calibre (software)|Calibre]], an E-book management application * [[Dropbox (service)|Dropbox]], a file hosting service * [https://earquiz.org/EQ_Frequencies/ EarQuiz Frequencies], a free and open-source application for EQ/frequency ear training * [[Electrum Bitcoin Wallet]] * [[Eric Python IDE]] * [[Frescobaldi_(software)|Frescobaldi]], a score editor for [[LilyPond]] music files * Kodos, a [[Python_(programming_language)|Python]] [[Regular expression]] Debugger * [[Leo (text editor)|Leo]], an outliner and literate programming editor * [[Ninja IDE|Ninja-IDE]], an extensible open-source [[Python_(programming_language)|Python]] IDE * [[OpenLP]], an open-source lyrics projection program * [[OpenShot]], a video editing program * [[Orange (software)|Orange]], a data mining and visualization framework * [[Puddletag]], an open-source, cross-platform ID3 tag editor * [[QGIS]], a free software desktop Geographic Information Systems (GIS) application * [[qutebrowser]], a web browser with Vim-style key bindings and a minimal GUI. * [[RecordMyDesktop|qt-recordMyDesktop]], a Qt4 frontend for recordMyDesktop * [[Spyder (software)|Spyder]], a [[Python_(programming_language)|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== {{Portal|Free and open-source software}} {{Commons category}} * [[PyGTK]] (Python wrappers for GTK) * [[PySide]] (Alternative Python wrapper for the Qt toolkit) * [[wxPython]] (Python wrapper for the wx widgets collection) * [[Kivy_(framework)|Kivy]] * [[Tkinter]] (bundled with Python) {{clear}} ==References== {{Reflist}} ==Further reading== *{{citation | first1 = Joshua | last1 = Willman | title = Beginning PyQt - A Hands-on Approach to GUI Programming | edition = 1st | date = 2020 | publisher = [[Apress]] | pages = 440 | isbn = 978-1-4842-5856-9 | url = https://www.apress.com/gp/book/9781484258569 }} *{{citation | first1 = Mark | last1 = Summerfield | title = Rapid GUI Programming with Python and Qt (Covers PyQt4) | edition = 1st | date = October 28, 2007 | publisher = [[Prentice Hall]] | pages = 648 | isbn = 978-0-13-235418-9 | url = http://www.qtrac.eu/pyqtbook.html }} *{{citation |first1 = Boudewijn |last1 = Rempt |title = GUI Programming with Python: QT Edition (Covers PyQt3) |year = 2002 |publisher = OpenDocs |url = http://www.commandprompt.com/community/pyqt/ |url-status = dead |archive-url = https://web.archive.org/web/20100409074937/http://www.commandprompt.com/community/pyqt/ |archive-date = 2010-04-09 }} ==External links== * {{Official website|http://www.riverbankcomputing.com/software/pyqt/}} * [https://wiki.python.org/moin/PyQt/ PyQt and PyKDE community Wiki] * [https://coderslegacy.com/python/pyqt6-tutorial-series/ PyQt6 Tutorial Series] * [https://coderslegacy.com/python/pyqt5-tutorial/ PyQt5 Tutorial Series] * [https://pythonspot.com/pyqt4/ PyQT4 tutorial series] * [http://www.rkblog.rk.edu.pl/w/p/introduction-pyqt4/ Tutorials] * [https://web.archive.org/web/20131023235117/http://zetcode.com/tutorials/pyqt4/ Tutorial] {{Qt}} {{Widget toolkits}} {{DEFAULTSORT:Pyqt}} [[Category:Articles with example Python (programming language) code]] [[Category:Cross-platform free software]] [[Category:Free computer libraries]] [[Category:Free software programmed in C++]] [[Category:Free software programmed in Python]] [[Category:Python (programming language) libraries]] [[Category:Qt (software)]] [[Category:Widget toolkits]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Citation
(
edit
)
Template:Cite book
(
edit
)
Template:Cite web
(
edit
)
Template:Clear
(
edit
)
Template:Commons category
(
edit
)
Template:Infobox
(
edit
)
Template:Infobox software
(
edit
)
Template:Main other
(
edit
)
Template:Official website
(
edit
)
Template:Portal
(
edit
)
Template:Qt
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Sister project
(
edit
)
Template:Template other
(
edit
)
Template:Widget toolkits
(
edit
)