Python37 GUI Qt5安装与使用
1.环境配置
cmd终端输入解析进行下载安装。
pip install PyQt5 -i https://pypi.douban.com/simple pip install PyQt5-tools -i https://pypi.douban.com/simple
2. QtDesigner的配置
打开pycham,file->setting,tool->External Tools
Program:D:\Python\Python37\Lib\site-packages\pyqt5_tools\Qt\bin\designer.exe
Working directory:$FileDir$
3.配置pyuic
Program:D:\Python\Python37\python.exe
Arguments:-m PyQt5.uic.pyuic $FileName$ -o $FileNameWithoutExtension$.py
Working directory:$FileDir$
4.PyQt5解决按钮文字显示不全等问题(利用屏幕的自适应设置)
必须放在main中的第一行, 完成了高清屏幕自适应设置
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
from PyQt5.QtCore import Qt if __name__ == '__main__': # 对于按钮文字显示不全的解决方法,必须放在main中的第一行, 完成了高清屏幕自适应设置 QApplication.setAttribute(Qt.AA_EnableHighDpiScaling) app = QApplication(sys.argv) myWin = MyMainWindow() myWin.show() sys.exit(app.exec_())