https://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.11.4/PyQt4-4.11.4-gpl-Py3.4-Qt4.8.7-x64.exe/download
1.4 安装过程
首先安装Python3.4.4 ,默认安装在 C:\Python34 文件下,建议安装全部组件,这里注意只要在第一步勾选添加到系统环境路径中即可。
再次安装PyQt4
安装程序会自动识别Python的安装路径,一般默认就是就是Python的安装目录。
1.5测试PyQt4是否安装成功
在Python开发环境下,执行下面的代码,查看是否生成了对话框
from __future__ import division
import sys
from math import *
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class Form(QDialog):
def __init__(self, parent=None):
super(Form, self).__init__(parent)
self.browser = QTextBrowser()
self.lineedit = QLineEdit("Type an expression and press Enter")
self.lineedit.selectAll()
layout = QVBoxLayout()
layout.addWidget(self.browser)
layout.addWidget(self.lineedit)
self.setLayout(layout)
self.lineedit.setFocus()
self.connect(self.lineedit, SIGNAL("returnPressed()"),
self.updateUi)
self.setWindowTitle("Calculate")
def updateUi(self):
try:
text = self.lineedit.text()
self.browser.append("%s = %s" % (text, eval(text)))
except:
self.browser.append(
"%s is invalid!" % text)
app = QApplication(sys.argv)
form = Form()
form.show()
app.exec_()