PyCharm PyQt5 开发环境搭建

环境

python:3.6.x

PyCharm:PyCharm 2019.3.5 (Community Edition)

安装PyQT5

pip install PyQt5 -i https://pypi.douban.com/simple
pip install PyQt5-tools -i https://pypi.douban.com/simple

配置PyCharm

PyCharm PyQt5 开发环境搭建_第1张图片

PyQtUIC

Program :D:\Python\Python36\python.exe

Arguments :-m PyQt5.uic.pyuic \$FileName\$ -o UI_\$FileNameWithoutExtension\$.py

Working directory :\$FileDir\$

PyQt5Designer

Program :D:\Python\Python36\Lib\site-packages\pyqt5_tools\designer.exe

Arguments :\$FileDir\$\\$FileName\$

Working directory :\$FileDir\$

PyQt5Qrc

Program :D:\Python\Python36\Scripts\pyrcc5.exe

Arguments :\$FileName\$ -o \$FileNameWithoutExtension\$_rc.py

Working directory :\$FileDir\$

示例代码

app.py

# coding:utf-8
from PyQt5 import QtWidgets
from Forms import MForm
import sys

if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    gui = MForm.MainUi()
    gui.show()
    sys.exit(app.exec_())

MForm.py

# coding:utf-8
from PyQt5 import QtWidgets,QtGui
from UI import UI_MainForm
from Resource import AppQrc_rc

class MainUi(QtWidgets.QMainWindow, UI_MainForm.Ui_MainWindow):
    '''
    主窗口
    '''
    def __init__(self):
        super(MainUi, self).__init__()
        self.setupUi(self)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(":/images/pictures/breads.png"),QtGui.QIcon.Normal)
        self.setWindowIcon(icon)
        self.setWindowTitle("测试窗口")

你可能感兴趣的:(Qt,qt,pyqt5,pycharm)