Window上VsCode中基于PyQt5的Python开发 之 环境搭建

Window上VsCode中基于PyQt5的Python开发 之 环境搭建

一、安装VsCode
二、安装Python
三、安装PyQt5 及其他模块
1、安装PyQt5:如:pip install pyqt5 -i https://pypi.douban.com/simple
2、安装PyQ5-tools:pip install pyqt5-tools -i https://pypi.douban.com/simple、
3、安装flake8:如:pip install flake8 -i https://pypi.douban.com/simple
4、安装yapf:如:pip install yapf -i https://pypi.douban.com/simple
5、项目配置设置
a)添加settings.json文件内容,如下:
{
"activestate.promptRuntimeCreation": false,
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
"python.formatting.provider": "yapf",
"python.linting.flake8Args": [
"--max-line-length=248",
"--disable=E1101",
"--disable=E1102",
],
}

四、安装VsCode的Python开发插件
1、安装插件Python:
2、安装插件PYQT Integration:

五、示例程序
import sys
import os

from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *

class GMainWindow(QMainWindow):
def init(self):
super().init()
self.initUI()

def initUI(self):
    self.initLayout()

    self.resize(500, 300)
    self.setWindowTitle('Echohelper')
    self.setWindowIcon(QIcon('logo.ico'))
    self.show()
    self.statusBar().showMessage('There is such a place that attracts you !')

def initLayout(self):
    btn = QPushButton('Quit', self)
    btn.resize(btn.sizeHint())
    btn.clicked.connect(qApp.quit)
    btn.move(50, 70)

if name == 'main':
app = QApplication(sys.argv)
ex = GMainWindow()
sys.exit(app.exec_())

六、示例程序截图

posted @ 2021-05-07 11:44  echohelper  阅读(746)  评论(0编辑  收藏  举报