Home arrow Python arrow Page 2 - PyQT: Getting Started

PyQT: Understanding the Terminology - Python

PyQT is used in Python for creating graphical user interfaces. This article gets you started with the basics of PyQT.

TABLE OF CONTENTS:
  1. PyQT: Getting Started
  2. PyQT: Understanding the Terminology
  3. Steps for PyQT Application Creation
  4. PyQT in the Real World
By: A.P.Rajshekhar
Rating: starstarstarstarstar / 12
March 29, 2006

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

The characteristic feature of any scripting language, including Python, is that it donít have a native GUI interface. But this has, in a way, become an advantage. Any existing GUI toolkit can be wrapped up and used as a binding for the language. This is exactly what Phil Thompson did when he wrapped QT, thus producing PyQT. In essence, PyQT is still has QT as its foundation. Hence understanding the basics and terminology of QT must come first. The most obvious question from the uninitiated is, what is QT? Thatís where I am going to begin.

What is QT?

By definition QT is ďa multi-platform C++ application framework which can be used by developers to write single-source applications capable of running natively on Windows, Linux, UNIX, Mac OS X and embedded Linux.Ē In short, it means write once, compile anywhere. The reason for this is that QT APIs are the same for all platforms and produce native executables.

This brings out another point. Doesnít Java promise the same thing? There is a big difference. Java achieves platform independence by means of a Virtual Machine, whereas in the case of QT, the source needs to be compiled for each of the target platforms. This helps keep it lightweight and significantly faster. 

Now that you know what QT is, the next important issue is understanding the types of Objects available on QT. There are two kinds of objects in QT, Visual Objects and Non-visual Objects.

Visual Objects includes menus, buttons, icons and so on. They are also known as Widgets. From here onwards  I will be referring to the Visual Objects as Widgets. All the Widgets are form objects.

Non-visual Objects are objects apart from Widgets that provide service but donít have any visible shape, size or such properties. Timers, painters etc. form a part of such objects. Though, they donít "exhibit" any visual properties, they are used on a par with Widgets. Timer (or QTimer) is the best example. It is not visible at runtime but almost all the multi-threaded applications use QTimer for their workings.

In a discussion on PyQT and for that matter QT, two terms figure prominently: Signals and Slots. These two represent the even-driven paradigm in the world of QT (and PyQT). I explain them in the next two paragraphs.

Signals are emitted by an object when its state changes. In other words, Signals are events that are generated when the internal properties of an object change. Whenever a Signal is emitted, the connected Slot is executed automatically, which is just like calling a function. The execution of Slots is independent of the GUI event loop. If a number of Slots are connected with a Signal, on the emitting of the Signals, these Slots are executed in an arbitrary manner.

Slots are simple functions that are called when a Signal is emitted. Though a Slot is a simple function, one feature makes it special: it can be connected to a signal. In other words, a Slot is a callback function. A Slot can be public, private, protected and even virtual (in terms of QT). The relationship between Signals and Slots is many-to-many.

Thatís all there is to understand about the basic terminology of QT and PyQT. The next step is to understand how QT is mapped with PyQT. The best way to understand this is to understand the steps involved in creating a PyQT application. That is what next segment is about.



 
 
>>> More Python Articles          >>> More By A.P.Rajshekhar
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PYTHON ARTICLES

- Python Big Data Company Gets DARPA Funding
- Python 32 Now Available
- Final Alpha for Python 3.2 is Released
- Python 3.1: String Formatting
- Python 3.1: Strings and Quotes
- Python 3.1: Programming Basics and Strings
- Tuples and Other Python Object Types
- The Dictionary Python Object Type
- String and List Python Object Types
- Introducing Python Object Types
- Mobile Programming using PyS60: Advanced UI ...
- Nested Functions in Python
- Python Parameters, Functions and Arguments
- Python Statements and Functions
- Statements and Iterators in Python

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: