http://[blog.csdn.net/pipisorry/article/details/37730443](http://blog.csdn.net/pipisorry/article/details/37730443)
目前发现的python下最好的图形库,wxpython、tkinter都觉得没这个好用。PyQt的核心是Qt(c++)库,一般不会占用太多时间的逻辑代码速度慢点,也不会成为瓶颈。同时,在使用方式上,PyQt并没有失去Python的优雅语法,快速开发的能力。
# **安装pythonQt**
OS: Windows 7 64bits
python version: 3.4
PyQt5下载 [Download](http://www.riverbankcomputing.com/software/pyqt/download5),选择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](http://movingthelamppost.com/blog/html/2013/07/12/installing_pyqt____because_it_s_too_good_for_pip_or_easy_install_.html)]
[[How to install PyQt4 on Windows using pip?](http://stackoverflow.com/questions/22640640/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中配置qtdesigner**
PyCharm > settings > tools > external tools > +添加
Qt Designer的设置如图:
![](https://box.kancloud.cn/2016-02-22_56ca830b93983.jpg)
**Note**:
1. Program选择PyQt安装目录中 designer.exe 的路径
2. Work directory 删除后使用变量 $FileDir$ (点击后面的 Insert macro 按钮来选择),我的是包目录E:\mine\python_workspace\PyQt
**Note**:$FileDir$ 指的是选中文件所在文件夹路径;$FileName$指的是选中文件的文件名
**pycharm中配置PyUIC**[](http://blog.csdn.net/pipisorry/article/details/45999965)
{用来将 Qt界面xml代码 转换成py代码}
PyUIC的设置类似qt designer,如图
![](https://box.kancloud.cn/2016-02-22_56ca830bad362.jpg)
program: Python安装路径
Parameters: -m PyQt5.uic.pyuic $FileName$ -o $FileNameWithoutExtension$.py
Work directory 使用变量 $FileDir$
配置完成后,pycharm菜单栏中tool的变化:
![](https://box.kancloud.cn/2016-02-22_56ca830bc9402.jpg)
![](https://box.kancloud.cn/2016-02-22_56ca830bd90ab.jpg)
### pycharm中配置Pyrcc
{这个是用于将qrc资源文件转换成py文件的工具的配置}
![](https://box.kancloud.cn/2016-02-22_56ca830be9b12.jpg)
如果在qt designer中使用了qrc资源文件,而没有将其转换为py文件就会出错:import error no module named resource_rc
[[ImportError: No module named resource_rc](http://pythontips.com/2014/03/08/importerror-no-module-named-resource_rc/)]
[皮皮blog](http://blog.csdn.net/pipisorry)
**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").
So if you only require the core PythonQt library (without complete Qt wrappers), it should be the work of 1-2 days and you can contribute the code to PythonQt. If you aim for the complete wrappers, using Qt4 wrappers is the easiest but will take some tweaking to adapt. Generating real Qt5 wrappers is more work.
[[sourceforge-PythonQt-Discussion](http://sourceforge.net/p/pythonqt/discussion/631392/thread/5f20c176/)]
[[PyQt 5.4参考指南 ---- PyQt5和PyQt4之间的差异](http://www.bubuko.com/infodetail-613067.html)]
from:[http://blog.csdn.net/pipisorry/article/details/37730443](http://blog.csdn.net/pipisorry/article/details/37730443)[](http://blog.csdn.net/pipisorry/article/details/45999965)
ref:[pythonqt example](http://pythonqt.sourceforge.net/Examples.html)
[Windows下PyQt4的安装](http://www.pythoner.com/83.html)