使用cx_Freeze打包PyQt4程序

来源:互联网 发布:淘宝管控记录异常订单 编辑:程序博客网 时间:2024/04/30 13:35
 PyQt源程序exam1.py:
  1. #!/usr/bin/env python
  2. import sys,sip    !!sip是Qt要求的,必须加
  3. from PyQt4 import QtGui,QtCore
  4. class MyWidget(QtGui.QWidget):
  5.     def __init__(self, parent=None):
  6.         QtGui.QWidget.__init__(self, parent)
  7.         self.setFixedSize(200120)
  8.         self.quit = QtGui.QPushButton("Quit"self)
  9.         self.quit.setGeometry(62407530)
  10.         self.quit.setFont(QtGui.QFont("Times"18, QtGui.QFont.Bold))
  11.         self.connect(self.quit, QtCore.SIGNAL("clicked()"),
  12.                      QtGui.qApp, QtCore.SLOT("quit()"))
  13. app = QtGui.QApplication(sys.argv)
  14. widget = MyWidget()
  15. widget.show()
  16. 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

原创粉丝点击