Install Python SDK in Windows
--------------------------------------------------------------------------------
There are many graphical development kits in Python, including tcl/tk, wxPython, PyGtk, and PyQt. Qt is the basic tool of KDE, which has good portability. It can be used on Linux, Windows, and other platforms. In Windows, it uses a local control. This article introduces how to install the PyQt development kit in windows and provides a small example.
I. Installation
First, install the Qt 2.3.0 Non-Commercial cial Edition package. It is a Non-Commercial development package in Windows and can be used for Non-Commercial development. You can download (http://www.trolltech.com/) from the Qt development homepage, which is about 10 MB in size. However, I found that the dynamic link library can be installed as long as it exists. Its name is: qt-mt230nc.dll. You can copy it to the windows/system directory. If needed, you can download it from my home page (http://pyrecord.126.com.
Then install the Python package. PyQt now supports Python 2.1 and 2.2. Therefore, you can use any version. I will not explain how to install Python.
Finally, install PyQt. Python versions with incorrect PyQt have different packages, of which 2.1 is 2.5 and 2.2 is 3.1. Can be downloaded from the PyQt homepage (http://www.riverbankcomputing.co.uk /). The installation is simple. Click the downloaded exe to execute the program. It may restart the machine once, and then automatically installs the machine after it is started. After the installation is complete, the PyQt item is added to the program group. Some examples can be used for testing.
Ii. PyQt programming example
To write a Hello, PyQt! Program as an example.
The Code is as follows:
1 import sys
2 from qt import *
3 a = QApplication (sys. argv)
4 hello = QPushButton ("Hello, PyQt! ", None)
5 hello. resize (100,30)
6 a. setMainWidget (hello)
7 hello. show ()
8 a.exe c_loop ()
Line 3 imports the qt module. Because Qt classes are well organized, they generally do not conflict with other modules.
Line 3 generates an application class and passes in command line parameters.
Generate a button in row 4th, and the button label is "Hello, PyQt! ".
Set the button size in row 5th.
Set the master control in row 6th.
The display button of Row 3.
Line 3 enters the event loop.
Iii. Additional instructions
Generally, Python programs end with. py. Therefore, when executing a program, a DOS window appears while displaying the window. How can this problem be solved? Simply change. py to. pyw.
I am not familiar with PyQt, but I hope to use this article to stimulate everyone's interest in learning PyQt. Because Qt has many classes, the PyQt documentation does not explain the Qt classes. If you install all the Qt 2.3.0 non-commercial software, there will be all Qt documents, these documents are good stuff. In addition, after Qt 2.3.0 is installed, a Qt Designer tool can be used to generate a user interface and save the uic file as an XML document. PyQt provides a tool called pyuic to convert uic files into Python code. This makes the design interface very convenient. This tool will be stored in the pythoninstallation directory after pyqtsoftware is installed. The file name is pyuic.exe.
Published on: 2002-7-6