Qt 的 Python 版本 PyQt 4.8.6 發布

fmms 13年前發布 | 26K 次閱讀 Python

PyQt是Qt庫的Python版本。PyQt3支持Qt1到Qt3。 PyQt4支持Qt4。它的首次發布也是在1998年,但是當時它叫 PyKDE,因為開始的時候SIP和PyQt沒有分開。PyQt是用SIP寫的。PyQt遵從奇趣的許可模式,有GPL版和商業版。

PyQt向Python程序員提供了使用完整Qt應用程序接口的方法。您幾乎可以用Python做任何C++能做的事。

既 然是應用程序接口,用C++或是Python都是一樣的。于是“為什么我得使用它”這個問題就可以歸結為編程語言的選擇上,而不一定要用PyQt。對我來 說作為一種編程語言,python相對于c++的優點是在編程效率上。您可以看到標準的Qt例子移植到PyQt后的代碼。它們具有相同的功能,使用相同的 應用程序接口,但Python版的代碼只有原來的50-60%,而且它們更容易閱讀。pyqt.gif

與編程效率相關的是Python更容易學習,而且它足以滿足富有經驗的程序員。奇趣公司已經發現PyQt可以使他們向應用高端技術的團體出售Qt,這些團體的成員是工業專家(化學家,航空工程師等)而不是精深的C++程序員。

當然PyQt既成熟又穩定,并且有龐大的用戶群體。我從用戶那兒得到的兩個最普通的反饋是“它恰到好處"和“它很不錯。”

它擁有以下模塊:

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 canvas widget capable of storing thousands of items including ordinary widgets.
  • The QtHelp module contains classes for creating and viewing searchable documentation and being able to integrate online help with PyQt applications. It is based on the C++ port of the Lucene text search engine.
  • The QtNetwork module contains classes for writing UDP and TCP clients and servers. It includes classes that implement FTP and HTTP clients and support 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 graphics in PyQt applications.
  • The QtScript module contains classes that enable PyQt applications to be scripted using Qt's JavaScript interpreter.
  • 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 QtTest module contains functions that enable unit testing of PyQt applications. PyQt does not implement the complete Qt unit test framework. Instead it assumes that the standard Python unit test framework will be used and implements those functions that simulate a user interacting with a GUI.
  • The QtWebKit module implements a web browser engine based on the WebKit open source browser engine used by Apple's Safari. It allows the methods and properties of Python objects to be published and appear as JavaScript objects to scripts embedded in HTML pages.
  • The QtXml module implements SAX and DOM interfaces to Qt's XML parser.
  • The QtXmlPatterns module implements XQuery and XPath support for XML and custom data models.
  • The phonon module implements a multimedia framework that enables the use of audio and video content in PyQt applications. On Windows DirectX is used as the backend, on MacOS/X QuickTime is used as the backend, and on Linux GStreamer is used as the backend.
  • The QtMultimedia module implements low-level multimedia functionality. Application developers would normally use the phonon module.
  • The QtAssistant module implements a simple interface for integrating Qt Assistant with PyQt applications to provide online help. Qt Assistant is itself implemented using QtHelp.
  • The QtDesigner module contains classes that allow Qt Designer to be extended using PyQt.
  • The QAxContainer module implements access to ActiveX controls and COM objects. It is only available in the commercial version of PyQt for Windows.
  • 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 DBus support module is installed as dbus.mainloop.qt. PyQt does not support Qt's native DBus classes. Instead the module enables the Qt event loop to be used with the standard DBus Python bindings. It is only available for PyQt for X11.
  • 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.

PyQt also contains a number of utility programs.

  • pyuic4 corresponds to the Qt uic utility. It converts GUIs created using Qt Designer to Python code.
  • pyrcc4 corresponds to the Qt rcc utility. It embeds arbitrary resources (eg. icons, images, translation files) described by an XML resource collection file in a Python module. These resources can then be accessed from a PyQt application as files in a virtual filesystem.
  • pylupdate4 corresponds to the Qt lupdate utility. It extracts all of the translatable strings from Python code and creates or updates translation files. These are then used by Qt Linguist to manage the translation of those strings.



PyQt 4.8.6 發布了,這是一個很小的 bug 修復版本。

項目地址:http://www.riverbankcomputing.com/software/pyqt/intro

 本文由用戶 fmms 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!