Introduction to PyQt4 toolkit

PyQT4工具包介绍

::-- zhuyj [2008-06-06 01:07:27]

1. About this tutorial

关于这篇教程

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.

  • 这是一篇关于 PyQT4教程的介绍。这篇教程的目的介绍PyQT4的工具包。

2. About PyQt

关于PyQt

PyQt 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 libraries on this planet. If not the most powerful. The official home site for PyQt is on www.riverbankcomputing.co.uk It was developed by Phil Thompson.

  • PyQT是一个生成图形应用程序的工具包。是python语言和成功的Qt库的绑定。Qt库是这个世界上最强大的库之一。官方的PyQt网站在www.riverbankcomputing.co.uk,由Phil Thompson开发。

PyQt 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. PyQt 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.

  • PyQT作为一组python的模块来实现。它包含了超过300个类,将近6000个函数和方法。它是一个多平台的工具包,可以在所有的主流操作系统上运行,包括Unic,Windows和Mac。PyQT采用双协议,开发者可以在GPL和商业授权中选择。以前的版本中,GPL版本只存在于Unic上。从PyQT4开始,GPL协议支持所有的平台。

Because there are a lot of classes available, they have been divided into several modules.

  • 因为存在很多的类,他们被分成了几个模块

Figure: PyQt4 Modules

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, colors, fonts etc. The QtNetwork module contains the classes for network programming. These classes allow to write TCP/IP and UDP clients and servers. They make 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.

  • QtCore模块包含了核心的非图形功能,这个模块被用来实现时间,文件和目录,不同的数据格式,流,互联网地址,mime类型,线程或进程等等。QtGui模块包含了图形组件和类的描述,包括例如按钮,窗口,状态栏,滑块,位图,颜色,字体等等。QtNetwork模块包含了网络编程所需的类,这些类可以用来实现TCP/IP和UDP的客户端/服务器程序,使得网络编程更加简单更加可移植。The QtXml模块提供了处理xml文件的类,这个模块包含了SAX和DOM APIs的实现。The QtSvg模块包含了显示SVG文件目录的类。Scalable Vector Graphics (SVG)是一种利用XML来描述二维图形和图形应用的的语言。QtOpenGL 模块用来通过OpenGL库来渲染3D和2D图形,这个模块实现了Qt GUI库和OpenGL库的无缝集合。QtSql模块提供了处理数据库的类。

3. Python

Python is a successful scripting language. It was initially developed by Guido van Rossum. It was first released in 1991. Python was inspired by ABC and Haskell programming languages. Python is a high level, general purpose, multiplatform, interpreted language. Some prefer to call it a dynamic language. It is easy to learn. Python is a minimalistic language. One of it's most visible features is that it does not use semicolons nor brackets. Python uses intendation instead. The most recent version of python is 2.5, which was released in September 2006. Today, Python is maintained by a large group of volunteers worldwide.

  • Python是一门很成功的脚本语言。最初由Guido van Rossum 发展。第一版于1991年发布。Python从ABC和Haskell编程语言获得灵感,Python是一种高阶的、常规用途的、多平台的解释语言。有些人更愿意称之为动态语言。它很容易入门。Python是一种简介的语言,它的最显著的特性之一就是不用使用分号或括号,而是使用回车和空格分隔语句和函数。 最新版本的Python是2.5,于2006年9月发布。今天,python由遍布全世界的一大群志愿者维护。

The TIOBE Programming Community Index gives us a theoretical usage of various programming languages. Java rules. The C++ language is detroned. But C++ will continue to be used in it's footholds for the coming decades and ther seems to be no real threat for it. We can clearly see specialization among programming languages. Java is used mainly in enterprise projects and portables, C is the king in system programming (OS, device drivers, small apps), PHP rules among small to medium size web sites, Javasript is used on the client site of a web application.

  • TIOBE编程社区索引显示了各种不同编程语言理论上的使用情况。java是桂冠,C++语言在降,但是C++会在立足于将来的十年一直被应用并且看起来没有对它的真正威胁。我们可以清楚的看到编程语言中特殊性。Java主要用在企业项目和可携带项目。C是系统编程之王(OS,设备驱动,小的应用),PHP统治小到中尺寸的网站,Javascript应用在网络应用的客户端。

Position

Language

Ratings

1

Java

21.7%

2

C

14.9%

3

Visual Basic

10.7%

4

PHP

10.2%

5

C++

9.9%

6

Perl

5.4%

7

C#

3.4%

8

Python

3.0%

9

JavaScript

2.7%

10

Ruby

2.0%

Python is currently number 8. The Ruby language has made into the toplist. The closest competitors to Python are Ruby and Perl.

  • Python目前位于第8位。Ruby语言刚进入前十。Python最接近的竞争者是Ruby和Perl。

4. Python toolkits

For creating graphical user interfaces, python programmers can choose among three decent options. PyGTK, wxPython and PyQt. Which toolkit to choose, depends on the circumstances. There is also another "option", called TkInter. Avoid.

  • 为了创建图形用户界面,python程序员可以在三个选项中选择,PyGTK,wxPython和PyQt。选择那种工具依赖于细节。并且还有另一种选择,叫做TkInter.

Name Password4deL ;) :( X-( B-)
zhuyj   Test!
2008-06-27 21:43:59
odzvemil ixrofzhe   jprhktz qdnfyb dgqh ljtne ftrhbx avkhu owimlysv
2008-07-30 20:21:34
mdwxst hkvfcd   cesnz ylbezv vqzyts awcfbod tjwsqempg wanvd yowftjc <A href="http://www.mbakrnvyx.xcvdufkp.com">wakvgtzr bkmcdnt</A>
2008-07-30 20:24:43
mdwxst hkvfcd   cesnz ylbezv vqzyts awcfbod tjwsqempg wanvd yowftjc <A href="http://www.mbakrnvyx.xcvdufkp.com">wakvgtzr bkmcdnt</A>
2008-07-30 20:25:08
rpxqnvhb xhjbdanv   pdwsvluti wrpcj htfj nwmyp gale kilgsefa gicknut [URL]http://www.wjqlhz.ypiob.com[/URL] mkjoin xdnyfa
2008-07-30 20:26:15