Thursday, April 11, 2013

Introduction to PyQt4

Introduction to PyQt4

This is an introductory PyQt4 tutorial. The purpose of this tutorial is to get you started with the PyQt4 toolkit. The tutorial has been created and tested on Linux.

About PyQt4

PyQt4 is a toolkit for creating GUI applications. It is a blending of Python programming language and the successfull Qt library. Qt library is one of the most powerful GUI libraries. The official home site for PyQt4 is on www.riverbankcomputing.co.uk/newsIt was developed by Phil Thompson.
PyQt4 is implemented as a set of Python modules. It has over 300 classes and almost 6000 functions and methods. It is a multiplatform toolkit. It runs on all major operating systems. Including Unix, Windows and Mac. PyQt4 is dual licenced. Developers can choose between GPL and commercial licence. Previously, GPL version was available only on Unix. Starting from PyQt version 4, GPL licence is available on all supported platforms.
Because there are a lot of classes available, they have been divided into several modules.
  • QtCore
  • QtGui
  • QtNetwork
  • QtXml
  • QtSvg
  • QtOpenGL
  • QtSql
The QtCore module contains the core non-gui functionality. This module is used for working with time, files and directories, various data types, streams, urls, mime types, threads or processes. The QtGui module contains the graphical components and related classes. These include for example buttons, windows, status bars, toolbars, sliders, bitmaps, colours, fonts etc. The QtNetwork module contains the classes for network programming. These classes facilitate the coding of TCP/IP and UDP clients and servers by making the network programming easier and more portable. The QtXml contains classes for working with XML files. This module provides implementation for both SAX and DOM APIs. The QtSvg module provides classes for displaying the contents of SVG files. Scalable Vector Graphics (SVG) is a language for describing two-dimensional graphics and graphical applications in XML. The QtOpenGL module is used for rendering 3D and 2D graphics using the OpenGL library. The module enables seamless integration of the Qt GUI libary and the OpenGL library. The QtSql module provides classes for working with databases.

Python

python logo Python is a general-purpose, dynamic, object-oriented programming language. The design purpose of the Python language emphasizes programmer productivity and code readability. Python was initially developed by Guido van Rossum. It was first released in 1991. Python was inspired by ABC, Haskell, Java, Lisp, Icon and Perl programming languages. Python is a high level, general purpose, multiplatform, interpreted language. Python is a minimalistic language. One of its most visible features is that it does not use semicolons nor brackets. Python uses indentation instead. There are two main branches of Python currently. Python 2.x and Python 3.x. Python 3.x breaks backward compatibility with previous releases of Python. It was created to correct some design flaws of the language and make the language more clean. The most recent version of Python 2.x is 2.7.1, and of Python 3.x 3.1.3. This tutorial covers Python 2.x versions. Most of the code is written in Python 2.x versions. It will take some time till the software base and programmers will migrate to Python 3.x. Today, Python is maintained by a large group of volunteers worldwide. Python is open source software.
Python is an ideal start for those, who want to learn programming.
Python programming language supports several programming styles. It does not force a programmer to a specific paradigm. Python supports object-oriented and procedural programming. There is also a limited support for functional programming.
The official web site for the Python programming language is python.org
As of August 2011, TIOBE Index ranks the Python language as the 8th most popular language. On langpop.com site it scores on the 6th place.
Perl, Python and Ruby are the most widely used scripting languages. They share many similarities. They are close competitors.

Python toolkits

For creating graphical user interfaces, Python programmers can choose among three decent options. PyQt4, PyGTK and wxPython. Which toolkit to choose, depends on the circumstances.
Due to some licensing issues and technical requirements a new binding of Qt to the Python language has been developed. The project is called PySide. PySide provides a high level compatibility with the PyQt4 toolkit.
This chapter was an introduction to PyQt4 toolkit.

No comments:

Post a Comment