安装PyQt5
1. 在命令窗口中输入下面两个命令:
pip install pyqt5
pip install pyqt5-tools
2. 打开PyCharm的File->Settings->Tools->External Tools,单击Add,在弹出的窗口中输入:
Name: QtDisigner Program : E:\anaconda3\Lib\site-packages\qt5_applications\Qt\bin\designer.exe Working directory: $FileDir$
3. 同样的方法,新建PyUIC:
Name: PyUIC Program : E:\anaconda3\python.exe Arguments: -m PyQt5.uic.pyuic $FileName$ -o $FileNameWithoutExtension$.py Working directory: $FileDir$
4. 再新建PyRCC:
Name: PyRCC Program: E:\anaconda3\Scripts\pyrcc5.exe Arguments: $FileName$ -o $FileNameWithoutExtension$_rc.py Working directory: $FileDir$
5. 创建一个空白页面:
import sys from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel app = QApplication(sys.argv) win = QMainWindow() win.setGeometry(400, 400, 400, 300) win.setWindowTitle("Pyqt5 Tutorial") win.show() sys.exit(app.exec_())