pyqt5安装
1 安装pyqt5 pyqt5_tools
2020.11.13 目前的最新版不能用,估计有bug
最新的pyqt5估计没问题,但是pyqt5_tools有问题,此时的最新版是5.15.1.2
pip install pyqt5-tools==
ERROR: Could not find a version that satisfies the requirement pyqt5-tools== (from versions: 5.9.2.1.3rc3, 5.9.2.1.3rc6, 5.9.2.1.3rc8, 5.9.2.1.3rc10, 5.9.2.1.3, 5.9.2.1.4rc0, 5.9.2.1.4rc1, 5.10.1.1.3rc3, 5.10.1.1.3rc6, 5.10.1.1.3rc8, 5.10.1.1.3rc10, 5.10.1.1.3, 5.10.1.1.4rc0, 5.10.1.1.4rc1, 5.10.1.1.4rc2, 5.10.1.1.4rc5, 5.10.1.1.4, 5.10.1.1.5rc0, 5.10.1.1.5rc4, 5.10.1.1.5, 5.10.1.1.6rc1, 5.11.2.1.3rc3, 5.11.2.1.3rc6, 5.11.2.1.3rc8, 5.11.2.1.3rc10, 5.11.2.1.3, 5.11.2.1.4rc1, 5.11.2.1.4rc2, 5.11.2.1.4rc5, 5.11.3.1.4rc0, 5.11.3.1.4, 5.11.3.1.6rc1, 5.12.1.1.5rc4, 5.12.3.1.5, 5.12.3.1.6rc1, 5.13.0.1.5, 5.13.1.1.6rc0, 5.13.2.1.6rc1, 5.14.0.1.7b3, 5.14.0.1.7, 5.14.0.1.7.1, 5.14.0.1.7.2, 5.14.0.1.7.3, 5.14.0.1.7.4, 5.14.0.1.7.5, 5.14.0.2, 5.14.1.1.7b3, 5.14.1.1.7, 5.14.1.1.7.1, 5.14.1.1.7.2, 5.14.1.1.7.3, 5.14.1.1.7.4, 5.14.1.1.7.5, 5.14.1.2, 5.14.2.1.7b2, 5.14.2.1.7b3, 5.14.2.1.7, 5.14.2.1.7.1, 5.14.2.1.7.2, 5.14.2.1.7.3, 5.14.2.1.7.4, 5.14.2.1.7.5, 5.14.2.2b1, 5.14.2.2, 5.15.0.1.7, 5.15.0.1.7.1, 5.15.0.1.7.2, 5.15.0.1.7.3, 5.15.0.1.7.4, 5.15.0.1.7.5, 5.15.0.2, 5.15.1.1.7.2, 5.15.1.1.7.3, 5.15.1.1.7.4, 5.15.1.1.7.5, 5.15.1.2b1, 5.15.1.2)
室友的稍老一点的能用
pip uninstall PyQt5
pip uninstall pyqt5-plugins
pip uninstall PyQt5-sip
pip uninstall pyqt5-tools
pip uninstall qt5-applications
pip install pyqt5==5.15.1
pip install pyqt5-tools==5.15.1.1.7.3
安装完成后将目录1下的两个dll复制到目录2下,直接覆盖就好。
两个dll是:qminimal.dll qwindows.dll
目录1:C:\Program Files\Python38\Lib\site-packages\pyqt5_tools\Qt\plugins\platforms
目录2:C:\Program Files\Python38\Lib\site-packages\pyqt5_tools\Qt\bin\platforms
2 在pycharm中配置external_tools
Pycharm中菜单栏依此点击File----Settings----Tools----External Tools-----点击“+”号,
按下图分别添加Qt Designer、PyUIC
2.1添加Qtdesigner
2.2添加PYUIC
3 Qt Designer工具栏菜单汉化(现在好像是在performance里直接设置,但是很沙雕呢,莫得卵用)
这是抄的人家博客的:https://www.cnblogs.com/deeplearning1314/p/10242477.html
下载designer_zh_CN.qm将它放在你的...\Lib\site-packages\pyqt5-tools\translations文件夹中,重新打开QT就汉化成功了
designer_zh_CN.qm的下载地址为:https://pan.baidu.com/s/1jzkumqjw-3VQiJxvo4V6Xw
4 pyqtdesigner 样例
地址:https://blog.csdn.net/huhuliuxia/article/details/52347091
#!/usr/bin/env Python
#coding: utf-8
from pic import Ui_MainWindow
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys,os
class Baby(QMainWindow,Ui_MainWindow):
def __init__(self,parent=None):
super(Baby,self).__init__(parent)
self.setupUi(self)
QObject.connect(self.pushButton_5, SIGNAL("clicked()"), self.change_show_laolaolaoye)
QObject.connect(self.pushButton_3, SIGNAL("clicked()"), self.change_show_yeyenainai)
QObject.connect(self.pushButton_4, SIGNAL("clicked()"), self.change_show_jiujiujiuma)
QObject.connect(self.pushButton_2, SIGNAL("clicked()"), self.change_show_tangtang)
QObject.connect(self.pushButton, SIGNAL("clicked()"), self.change_show_babamama)
QObject.connect(self.pushButton_6, SIGNAL("clicked()"), self.change_show_yangzai)
def change_show_babamama(self):
self.label_2.setPixmap(QPixmap("img/babamama.png"))
def change_show_yeyenainai(self):
self.label_2.setPixmap(QPixmap("img/yeyenainai.png"))
def change_show_jiujiujiuma(self):
self.label_2.setPixmap(QPixmap("img/jiujiujiuma.png"))
def change_show_tangtang(self):
self.label_2.setPixmap(QPixmap("img/tangtang.png"))
def change_show_yangzai(self):
self.label_2.setPixmap(QPixmap("img/laolao.png"))
def change_show_laolaolaoye(self):
self.label_2.setPixmap(QPixmap("img/laolaolaoye.png"))
if __name__ == '__main__':
app = QApplication(sys.argv)
form = Baby()
form.show()
app.exec_()