http://blog.csdn.net/pipisorry/article/details/37730443
目前发现的python下最好的图形库,wxpython、tkinter都觉得没这个好用。PyQt的核心是Qt(c++)库,一般不会占用太多时间的逻辑代码速度慢点,也不会成为瓶颈。同时,在使用方式上,PyQt并没有失去Python的优雅语法,快速开发的能力。
OS: Windows 7 64bits
python version: 3.4
PyQt5下载 Download,选择PyQt5-5.5.1-gpl-Py3.4-Qt5.5.1-x64.exeWindows 64 bit installer下载并安装
Note:
1. 注意选择正确的Python版本和系统位数。
2. 安装PyQt并不需要一些文章中提到的先安装sip和Qt的过程,因为在安装文件中已经包括。
pyqt直接用exe文件安装较好,pip安装比较复杂。
[Installing PyQt... because it’s too good for pip or easy_install]
[How to install PyQt4 on Windows using pip?]
测试是否安装成功
import PyQt5
没报错说明安装成功
皮皮blog
pythonQt Designer配置
pyqt提供了Qt designer来设计窗口界面,用起来也非常方便,虽然做出来的界面不那么华丽。
增加系统变量QT_QPA_PLATFORM_PLUGIN_PATH
D:\python3.4.2\Lib\site-packages\PyQt5\plugins
Note:这是你安装pyqt目录下的插件目录
PyCharm > settings > tools > external tools > +添加
Qt Designer的设置如图:
Note:
1. Program选择PyQt安装目录中 designer.exe 的路径
2. Work directory 删除后使用变量 $FileDir$ (点击后面的 Insert macro 按钮来选择),我的是包目录E:\mine\python_workspace\PyQt
Note:$FileDir$ 指的是选中文件所在文件夹路径;$FileName$指的是选中文件的文件名
pycharm中配置PyUIC
{用来将 Qt界面xml代码 转换成py代码}
PyUIC的设置类似qt designer,如图
program: Python安装路径
Parameters: -m PyQt5.uic.pyuic $FileName$ -o $FileNameWithoutExtension$.py
Work directory 使用变量 $FileDir$
配置完成后,pycharm菜单栏中tool的变化:
{这个是用于将qrc资源文件转换成py文件的工具的配置}
如果在qt designer中使用了qrc资源文件,而没有将其转换为py文件就会出错:import error no module named resource_rc
[ImportError: No module named resource_rc]
皮皮blog
PyQT5和PyQt4的区别
Porting to Qt5 has two aspects:
1) Getting the core PythonQt to build (that should be merely adjusting the qmake profile and maybe some incompatibilities in QMetaObject and friends)
2) Getting the Qt 4 wrappers to work (run the pythonqt_generator and see what happens… Some extra includes and fixes in the typesystem might be required)
The Qt wrappers could be done in two ways: Qt4 backward compatible (With widgets being located in PythonQt.QtGui) or Qt5 only (with widgets being located in a new PythonQt.QtWidgets package).
PyQt5的Widget被分离出来,似乎用来替代Dialog,并将Widget放入了QtWidget模块(库)中,PyQt4是QtGUI。
I would also think it might be useful to watch what PySide and PyQt are doing in that respect (google for "PySide Qt5" or "PyQt Qt5").
[sourceforge-PythonQt-Discussion]
[PyQt 5.4参考指南 ---- PyQt5和PyQt4之间的差异]
TkInter的使用
[使用 Python 的 Tkinter模块 开发 IRC 客户端]
from:http://blog.csdn.net/pipisorry/article/details/37730443
ref:pythonqt example
Windows下PyQt4的安装