PyQt

PyQt

Developer(s) Riverbank Computing
Stable release 5.5.1 / October 25, 2015 (2015-10-25)[1]
Written in C++ / Python[2]
Operating system Cross-platform
License GNU GPL and commercial
Website riverbankcomputing.com

PyQt is a Python binding of the cross-platform GUI toolkit Qt. It is one of Python's options for GUI programming. Popular alternatives are PySide (the Qt binding with official support and a more liberal licence), PyGTK, wxPython, and Tkinter (which is bundled with Python). Like Qt, PyQt is free software. PyQt is implemented as a Python plug-in.

PyQt is 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 (GPL) and commercial license, but not the GNU Lesser General Public License (LGPL).[3] PyQt supports Microsoft Windows as well as various flavours of Unix, including Linux and OS X.[4]

PyQt implements around 440 classes and over 6,000 functions and methods[5] including:

To automatically generate these bindings, Phil Thompson developed the tool SIP, which is also used in other projects.

In August 2009, Nokia, the then owners of the Qt toolkit, released PySide, providing similar functionality, but under the LGPL,[8] after failing to reach an agreement with Riverbank Computing[9] to change its licensing terms to include LGPL as an alternative license.

Alternative PyQt logo

PyQt main components

PyQt4 contains the following Python modules.

Versions

PyQt version 4 works with both Qt 4 and Qt 5. PyQt version 5 only supports Qt version 5,[4] and drops support for features that are deprecated in Qt 5.[11]

Hello world example

The below code shows a small window on the screen.

#! /usr/bin/env python
# -*- coding: 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.
a = 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. 
w = QWidget()

w.resize(320, 240)  # The resize() method resizes the widget.
w.setWindowTitle("Hello, World!")  # Here we set the title for our window.
w.show()  # The show() method displays the widget on the screen.

sys.exit(a.exec_())  # Finally, we enter the mainloop of the application.

Notable applications that use PyQt


Wikimedia Commons has media related to PyQt.

References

  1. PyQt v5.5.1 Released
  2. "PyQt4 Download". Riverbankcomputing. 2010. Retrieved 2010-04-19.
  3. "Riverbank | Commercial | License FAQ". Riverbankcomputing.com. Retrieved 2015-06-24.
  4. 1 2 "What is PyQt?". Riverbank Computing. Retrieved 2014-09-18.
  5. "PyQt v4 - Python Bindings for Qt v4". Riverbankcomputing. Retrieved 2010-04-17.
  6. "QSqlDatabase Class Reference". Pyqt.sourceforge.net. Retrieved 2014-09-25.
  7. PythonInfo Wiki
  8. "PySide has been released – PySide – Python for Qt". Pyside.org. 2009-08-18. Retrieved 2009-09-03.
  9. "FAQ – PySide – Python for Qt". Pyside.org. Retrieved 2009-09-03.
  10. "Riverbank | Software | PyQt | What is PyQt?". Riverbankcomputing.co.uk. Retrieved 2010-04-15.
  11. "Differences Between PyQt4 and PyQt5", PyQt 5.3.2 Reference Guide

Further reading

External links

This article is issued from Wikipedia - version of the Sunday, March 27, 2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.