PyQt5 5.10.1 + SIP 4.19.8 + Eric6

什么是SIP:
SIP is a tool that makes it very easy to create Python bindings for C and C++ libraries. It was originally developed to create PyQt, the Python bindings for the Qt toolkit, but can be used to create bindings for any C or C++ library.
我的理解:
SIP 是python 和 C/C++的粘合剂(binding),可以把C/C++的库转化为python的模块来调用。

什么是PyQt:
PyQt is a set of Python v2 and v3 bindings for The Qt Company's Qt application framework and runs on all platforms supported by Qt including Windows, OS X, Linux, iOS and Android. PyQt5 supports Qt v5. PyQt4 supports Qt v4 and will build against Qt v5. The bindings are implemented as a set of Python modules and contain over 1,000 classes.
我的理解:
PyQt是用SIP这个工具,针对Qt的库生成了bindings,将之作为python的库来调用。
所以在编辑python代码的时候,引用PyQt这个binding,就可以实现界面的功能。

什么是Eric6:
PyQt官网推荐的IDE

什么是QScintilla:
QScintilla是源代码编辑控件Scintilla针对Qt的接口,它支持自动补全、代码折叠等功能。

什么是Python虚拟环境:
python虚拟环境是一个隔离/独立的python开发环境,和系统python环境可以完全隔离。
我的理解:
好像独立出一个虚拟机的感觉,每个虚拟机里是不同的Python工作环境,安装不同的模块。

我电脑上原本的环境:
VS2013
Qt 5.10.1
python3.6.2

版本选择:
PyQt5 5.10.1:
由于我之前安装的是5.10.1,所以选择了PyQt5 5.10.1.
SIP 4.19.8:
后来编译的时候遇到最新的SIP不能兼容PyQt5 5.10.1,会出现“Unable to create the C++ code)”的报错,所以最终参考别人的文章选择了 SIP 4.19.8

一、安装PyQt5 和 SIP
1、解压缩:
将这个两个压缩包都解压缩到了C盘根目录。
之前我本来是在桌面编译的,由于OneDrive的原因,会使桌面这个路径里面有个"-" ,导致编译不通过,所以挪到了C盘根目录。

2、编译安装SIP
# Step1.先运行C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat 配置编译环境
> "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat"
# Step2.进入sip源码目录
> cd C:\sip-4.19.8
# Step3.获得Makefile文件
> python3 configure.py
# Step4. nmake
> nmake
# Step5. 安装
> nmake install

3、编译安装PyQt5
cd C:\PyQt5_gpl-5.10.1 > python3 configure.py --verbose

4、第一个程序hello world
新建个pyqt5 hello world.py,用python3的IDE打开,输入下面的代码:

import sys
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtWidgets import QMainWindow, QLabel, QGridLayout, QWidget
from PyQt5.QtCore import QSize    

class HelloWindow(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)

        self.setMinimumSize(QSize(640, 480))    
        self.setWindowTitle("Hello world - pythonprogramminglanguage.com") 

        centralWidget = QWidget(self)          
        self.setCentralWidget(centralWidget)   

        gridLayout = QGridLayout(self)     
        centralWidget.setLayout(gridLayout)  

        title = QLabel("Hello World from PyQt", self) 
        title.setAlignment(QtCore.Qt.AlignCenter) 
        gridLayout.addWidget(title, 0, 0)

if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    mainWin = HelloWindow()
    mainWin.show()
    sys.exit( app.exec_() )

5、hello world的运行结果:

参考文档:
https://blog.csdn.net/humanking7/article/details/80393070

二、下载安装Eric6

1、在官网下载安装包
2、安装所有dependencies,

我这里欠缺了QScintilla,安装之:
pip3 install QScintilla
3、解压,进入Eric6文件夹
pip3 install.py
4、运行Eric6
在开始菜单中输入Eric6,看到蛇头的图标了,于是运行。
(看到别的教程里说必须运行pyw文件才能启动Eric6,可我直接就可以,是不是Eric改进了。)

三、创建Python虚拟环境(可以选择在虚拟环境中安装eric6 我是没有成功)
1、安装Python虚拟环境
pip3 install virtualenv
注:有两种虚拟环境venv( for python3.3以上)和 virtualenv(python2.7+和python3.3+都可)。

2、创建虚拟环境
虚拟环境创建之后,在本地表现为一个文件夹,所以我在本地单读建了一个文件夹来装虚拟环境:
c:\mkdir Python362_env
创建第一个虚拟环境:
cd Python362_env
C:\Python362_env\ virtualenv env01
(用virtualenv这个模块来创建虚拟环境)
or
python3 -m venv C:\Python362_env\ env01
(用venv这个模块来创建虚拟环境,-m 是让python3使用venv这个模块)

3、使用虚拟环境:
cd env03
cd Scripts
进入虚拟环境:
activate
退出虚拟环境
deactivate

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值