环境
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
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文章来源:https://www.toymoban.com/news/detail-674968.html
# 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文章来源地址https://www.toymoban.com/news/detail-674968.html
# 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("测试窗口")
到了这里,关于PyCharm PyQt5 开发环境搭建的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!