开始Python之旅

来源:互联网 发布:裕津 知乎 编辑:程序博客网 时间:2024/05/21 21:34

参照

http://www.saltycrane.com/blog/2007/01/how-to-install-pyqt-41-python-25-and-qt_8340/

安装PyQT4环境。

 

Here are the steps to install and create a simple "Hello World" GUI application using PyQt 4.4, and Python 2.5, on Windows.


Install Python 2.5

  1. Go to http://www.python.org/download/ and click on "Python 2.5.x Windows installer"
  2. Save and run the Windows installer
  3. Go through the steps and accept the defaults.


Install the PyQt 4.4 bundle (including QT 4.4)

  1. Go to http://www.riverbankcomputing.co.uk/software/pyqt/download and select the "PyQt-Py2.5-gpl-4.4.2-1.exe" link.
  2. Save and run the file.
  3. Go through the steps and accept the defaults.


Run a "Hello World" application

  1. Go to "Start" -> "All Programs" -> "Python 2.5" -> "IDLE (Python GUI)"
  2. Open a new window ("File" -> "New window")
  3. Type the following code inside and save:
    import sys
    from PyQt4.QtGui import *
    app = QApplication(sys.argv)
    button = QPushButton("Hello World", None)
    button.show()
    app.exec_()
  4. Hit "F5" to run. A window with a single push button should pop up.

For more examples, go to "Start" -> "All Programs" -> "PyQt GPL v4.4.2 for Python v2.5" > "Examples" > "PyQt Examples Source" (For a default installation, this is also located at C:/Python25/PyQt4/examples.) To start, look in the "tutorial" directory.

 

安装Python 2.7和对应的PyQT4-Py2.7包成功,不再需要另装MinGW。