利用 PyCharm 搭建 PyQt5 开发环境
Guide to install PyQt5 on Mac OS X with python 3.4 virtualenv
记录一下之前配置 PyQt 开发环境的步骤,最终效果: 通过 Pycharm 运行 Qt Designer 设计界面;并能从 Pycharm 中利用 PyUic 直接将工程中选定的.ui 文件转换为.py 文件
Prerequisite
- python >= 3.2
- Qt libraries >= 5
- SIP 4.x
- PyQt 5.x
- xcode 5.x
- Qt Designer
- Pycharm
Dowload
Dowload SIP and PyQt5 from Riverbank
Set Virtual Environment
1 | pip install virtualenv |
Installation
1 | cd /usr/bin/local |
Test For PyQt5
1 | python -c "import PyQt5" |
Set Up PyQt5 On Pycharm
Use cmd + ',' to open preference in Pycharm. Look for 'External Tools'. Add tools as follow:
Parameters in '2.png':
1 | -m PyQt5.uic.pyuic $FileName$ -o$FileNameWithoutExtension$.py |
Usage
- Set the python interpreter the one in your virtualenv
- Open
Tools -> External Tools -> QtDesigner
to edit .ui file - Chose the .ui file and use
Tools -> External Tools -> PyUic
to transform .ui into .py