* 安装html
安装包python
要对应python的版本web
32位安装包(我PC上)windows
或 64位安装包ide
安装目录ui
指定python目录便可,如 C:\Python27\this
运行spa
参考 http://www.pythoner.com/111.html
* 使用
API文档看这里
简单UI开发
手工编辑代码
实用UI开发
- eric4/eric5
提供UI编辑功能
http://nchc.dl.sourceforge.net/project/eric-ide/eric5/stable/5.5.0/eric5-5.5.0.zip
- 安装(windows)
1.解压到eric5-5.5.0
2.在 eric5-5.5.0/下命令行执行 python install.py
- 启动
1.在 eric5-5.5.0/eric/下,双击 eric.pyw
- qt designer
- 编辑UI,生成xxx.ui文件
- 用ui文件生成py代码
pyuic4 -o 文件名.py 项目名.ui
-x 选项 该参数表示是否生成额外的测试代码来显示窗口,建议加上该参数,这样的话能够方便直接调试运行。
- 生成的py文件
包含 Ui_Dialog 类做为界面描述代码
- 能够直接编辑,做为项目主文件
如加入如下代码后可运行
if __name__ == "__main__": import sys app = QtGui.QApplication(sys.argv) Dialog = QtGui.QDialog() ui = Ui_Dialog() ui.setupUi(Dialog) Dialog.show() sys.exit(app.exec_())
打包
- py2exe打包成exe
- 安装(windows)
下载对应python版本的安装包
http://ncu.dl.sourceforge.net/project/py2exe/py2exe/0.6.9/py2exe-0.6.9.win32-py2.7.exe
- 依赖
MSVCP90.dll (不清楚为何只是要这个文件,其余的 MSVCPxxx.dll 彷佛都不行)
放置在C:\Windows\System32下
- 使用
将该文件放置要打包的项目目录下,要打包时双击执行,在dist/下生成可执行文件(该文件 setup.windows 中指定的名称)
""" 文件名qt_pkg_tools.py ,如下才是源代码""" #!/usr/bin/env python #coding=utf-8 from distutils.core import setup import py2exe import sys #this allows to run it with a simple double click. sys.argv.append('py2exe') py2exe_options = { "includes": ["sip"], "dll_excludes": ["MSVCP90.dll",], "compressed": 1, "optimize": 2, "ascii": 0, "bundle_files": 1, } setup( name = 'PyQt Demo', version = '1.0', windows = ['pyqtdemo.py',], zipfile = None, options = {'py2exe': py2exe_options} )
* FAQ
打包后,运行时失败
打包后执行时,有时仍是会提示缺乏MSVCP90.dll,删除掉dist/目录,从新生成便可