PyQt源程序exam1.py:
打包命令:
D:/liusp/study/pyQT/exams>d:/cx_Freeze-3.0.3/FreezePython.exe
--shared-lib-name=d:/Python25/lib/site-packages/PyQt4/QtCore4.dll
--shared-lib-name=d:/Python25/lib/site-packages/PyQt4/QtGui4.dll
--shared-lib-name=d:/python25/lib/site-packages/PyQt4/mingwm10.dll
--install-dir dist exam1.py
这三个dll都是PyQt运行时需用到的,最后一行指定打包输出目录。
打包完成后得到dist目录,其包含如下文件:
exam1.exe mingwm10.dll PyQt.QtCore.pyd PyQt4.QtGui.pyd python25.dll QtCore4.dll QtCore4.dll sip.pyd
- #!/usr/bin/env python
- import sys,sip !!sip是Qt要求的,必须加
- from PyQt4 import QtGui,QtCore
- class MyWidget(QtGui.QWidget):
- def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
- self.setFixedSize(200, 120)
- self.quit = QtGui.QPushButton("Quit", self)
- self.quit.setGeometry(62, 40, 75, 30)
- self.quit.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
- self.connect(self.quit, QtCore.SIGNAL("clicked()"),
- QtGui.qApp, QtCore.SLOT("quit()"))
- app = QtGui.QApplication(sys.argv)
- widget = MyWidget()
- widget.show()
- sys.exit(app.exec_())
D:/liusp/study/pyQT/exams>d:/cx_Freeze-3.0.3/FreezePython.exe
--shared-lib-name=d:/Python25/lib/site-packages/PyQt4/QtCore4.dll
--shared-lib-name=d:/Python25/lib/site-packages/PyQt4/QtGui4.dll
--shared-lib-name=d:/python25/lib/site-packages/PyQt4/mingwm10.dll
--install-dir dist exam1.py
这三个dll都是PyQt运行时需用到的,最后一行指定打包输出目录。
打包完成后得到dist目录,其包含如下文件:
exam1.exe mingwm10.dll PyQt.QtCore.pyd PyQt4.QtGui.pyd python25.dll QtCore4.dll QtCore4.dll sip.pyd