Python using QT5 development interface of a demo development process summary
1. Current python version:
p>
2. Use PIP to install QT5:
pip install pyqt5
p>
Pyqt5-tools: PIP install pyqt5-tools
p>
4. Check whether QT was installed successfully:
from PyQt5 import QtWidgets, QtGui
import sys
app = QtWidgets.QApplication(sys.argv)
window = QtWidgets.QWidget();
window.show()
sys.exit(app.exec_())
pops out the following interface :
p>
Pycharm related configuration :
1. Add external Tools
open Settings – & gt; Tools-> External Tools click “+”
p>
p>
2. Add QtDesigner
set
as shown below
p>
3. Add PyUIC
is set as shown below.
Parameters: -m pyqt5.uic. Pyuic $FileName$-o $FileNameWithoutExtension$.py
Parameters: -m pyqt5.uic. Pyuic $FileName$-o $FileNameWithoutExtension$.py
p>
p>
3. Create a new PyQt demo and create a project
as shown below
p>
Open QtDesigner
p>
p>
open Qt interface as shown in the figure below
p>
p>
create a Main Window
p>
as shown in the figure, you can add your own component
as needed
p>
save
as shown
p>
as shown below, use PyUIC to convert hello. UI file to hello.py
and here’s what I did:
# -*- coding: utf-8 -*-
from helloworld import Ui_MainWindow
from PyQt5 import QtCore, QtGui, QtWidgets
import sys
class query_window(QtWidgets.QMainWindow):
def __init__(self):
QtWidgets.QMainWindow.__init__(self)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.ui.pushButton.clicked.connect(self.query_formula)
# 给button 的 点击动作绑定一个事件处理函数
def query_formula(self):
pass
# 此处编写具体的业务逻辑
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
window = query_window()
window.show()
sys.exit(app.exec_())
p>
p>
p>
div>