当前位置:网站首页>(5) Pyqt5 series tutorials: use pychart to design the internal logic of pyqt5 in the serial port assistant parameter options (II)
(5) Pyqt5 series tutorials: use pychart to design the internal logic of pyqt5 in the serial port assistant parameter options (II)
2022-07-21 03:32:00 【Kkh_ eight thousand six hundred and eighty-six】
( 5、 ... and )PyQt5 Series of tutorials : Use Pycharm Yes PyQt5 Carry out internal logic design in the serial port assistant parameter options ( Two )
1. QSpinBox Counter control :
picture source : IOT Inn .
2. Name the counter (spinBox) Control object is “spin_01_send”
3. Logic code :
import sys
from PyQt5 import QtWidgets
import USART_select_03
# Build a class usartMainWindow
class usartMainWindow(QtWidgets.QMainWindow,USART_select_03.Ui_MainWindow):
def __init__(self): # initialization
super().__init__()
self.setupUi(self)
# Initialize serial port assistant (ASCII perhaps Hex) The choice of (radio_Buttom)
self.radioButton_recv_ascii.setChecked(True)
self.radioButton_send_ascii.setChecked(True)
# initialization SpinBox Time range setting (100,30000), Step number setting (100), loop , Initial value (100)
self.spinBox_01_send.setRange(100, 30*1000)
self.spinBox_01_send.setSingleStep(100)
self.spinBox_01_send.setWrapping(True)
self.spinBox_01_send.setValue(1000)
# Bind signal to slot ######################################################################
# When comboBox_baud( Current baud rate ) change , Bind to comboBox_baud_cb event
self.comboBox_baud.currentIndexChanged.connect(self.comboBox_baud_cb)
# When btn_send( Button clicked ), Binding connection btn_send_cd event
self.btn_send.clicked.connect(self.btn_send_cb)
# The beginning of the menu bar 、 Pause 、 stop it 、 Clear the key operation
self.action_Start.triggered.connect(self.action_start_cb)
self.action_Pause.triggered.connect(self.action_pause_cb)
self.action_Stop.triggered.connect(self.action_stop_cb)
self.action_Clean.triggered.connect(self.action_clean_cb)
# Receive settings 、 Send settings (radio_Buttom) Single click event binding triggers
self.radioButton_send_ascii.clicked.connect(self.radioButton_send_ascii_cb)
self.radioButton_send_hex.clicked.connect(self.radioButton_send_hex_cb)
self.radioButton_recv_ascii.clicked.connect(self.radioButton_recv_ascii_cb)
self.radioButton_recv_hex.clicked.connect(self.radioButton_recv_hex_cb)
# Detect word wrap 、 Show send 、 Display time 、 Repeat send button , Bind signal to slot
self.checkBox_auto_line.toggled.connect(self.checkBox_auto_line_cb)
self.checkBox_show_send.toggled.connect(self.checkBox_show_send_cb)
self.checkBox_show_time.toggled.connect(self.checkBox_show_time_cb)
self.checkBox_resend.toggled.connect(self.checkBox_resend_cb)
# timer SpinBox
self.spinBox_01_send.valueChanged.connect(self.spinBox_cb)
# The event corresponding to the signal triggers #########################################################################
# Baud rate event
def comboBox_baud_cb(self):
content = self.comboBox_baud.currentText()
print("combox's value is ", content)
text = (" You currently selected %s" %content)
QtWidgets.QMessageBox.information(self, " Tips ", text, QtWidgets.QMessageBox.Ok |QtWidgets.QMessageBox.Cancel)
# Click the send event button
def btn_send_cb(self):
print("you clicked btn_send.")
text = self.textEdit_get.toPlainText() # Get objects textEdit_get The text in the
print("text is ", text)
# Put the object textEdit_get Text in box , Load into object comboBox_uart in
self.comboBox_uart.addItem(text)
# The event triggered by clicking the start button of the menu (Start、Pause、Stop、Clean)
def action_start_cb(self):
print("you clicked action_start")
# The event triggered by clicking the pause button of the menu
def action_pause_cb(self):
print("you clicked action_pause")
# The event triggered by clicking the stop button of the menu
def action_stop_cb(self):
print("you clicked action_stop")
# The event triggered by clicking the clear button of the menu
def action_clean_cb(self):
print("you clicked action_clean")
# The event triggered when the radio button is checked (ASCII send out 、Hex send out 、ASCII receive 、Hex receive )
def radioButton_send_ascii_cb(self):
print("you selected radioButton_send_ascii")
def radioButton_send_hex_cb(self):
print("you selected radioButton_send_hex")
def radioButton_recv_ascii_cb(self):
print("you selected radioButton_recv_ascii")
def radioButton_recv_hex_cb(self):
print("you selected radioButton_recv_hex")
# checkBox Events trigger ( Automatic line feed 、 Show send 、 Display time 、 Repeat send ) Judge whether it is selected
def checkBox_auto_line_cb(self):
print("you select checkBox_auto_line")
res_auto_line = self.checkBox_auto_line.isChecked()
print("res_auto_line is ", res_auto_line)
res_show_send = self.checkBox_show_send.isChecked()
print("res_show_send ", res_show_send)
res_show_time = self.checkBox_show_time.isChecked()
print("res_show_timw ", res_show_time)
res_repeat_send = self.checkBox_resend.isChecked()
print("rec_resend is ", res_repeat_send)
def checkBox_show_send_cb(self):
print("you select checkBox_show_send")
print("you select checkBox_auto_line")
res_auto_line = self.checkBox_auto_line.isChecked()
print("res_auto_line is ", res_auto_line)
res_show_send = self.checkBox_show_send.isChecked()
print("res_show_send ", res_show_send)
res_show_time = self.checkBox_show_time.isChecked()
print("res_show_timw ", res_show_time)
res_repeat_send = self.checkBox_resend.isChecked()
print("rec_resend is ", res_repeat_send)
def checkBox_show_time_cb(self):
print("you select checkBox_show_time")
print("you select checkBox_auto_line")
res_auto_line = self.checkBox_auto_line.isChecked()
print("res_auto_line is ", res_auto_line)
res_show_send = self.checkBox_show_send.isChecked()
print("res_show_send ", res_show_send)
res_show_time = self.checkBox_show_time.isChecked()
print("res_show_timw ", res_show_time)
res_repeat_send = self.checkBox_resend.isChecked()
print("rec_resend is ", res_repeat_send)
def checkBox_resend_cb(self):
print("you select checkBox_resend")
print("you select checkBox_auto_line")
res_auto_line = self.checkBox_auto_line.isChecked()
print("res_auto_line is ", res_auto_line)
res_show_send = self.checkBox_show_send.isChecked()
print("res_show_send ", res_show_send)
res_show_time = self.checkBox_show_time.isChecked()
print("res_show_timw ", res_show_time)
res_repeat_send = self.checkBox_resend.isChecked()
print("rec_resend is ", res_repeat_send)
# timer SpinBox
def spinBox_cb(self):
value = self.spinBox_01_send.value()
print("SpinBox_01_send value is ", value)
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
MainWindow = usartMainWindow()
MainWindow.show()
sys.exit(app.exec_())
The real-time value of the counter is displayed and extracted , effect :
边栏推荐
- P1926 little bookboy - question brushing Army (DP backpack (01 backpack) state transition equation)
- 小白教程--anaconda之Jupyter Notebook自动补全配置教程
- 李宏毅2020机器学习笔记---P10 Classification
- P1913 paratroopers in battle
- kettle_配置数据库连接_报错
- SQL processing data synchronization group analysis
- 达梦AWR报告提取
- 关于编码(ASCII / Unicode / UTF8)
- xcode编译 build号自增
- Centos8(linux)安装mysql8.0.28
猜你喜欢
随机推荐
Flink 分流之 Filter/Split/SideOutPut 比较
Redis持久化
JDBC 学习笔记
微服务理论介绍
Mysql 主从复制 docker集群搭建
User login demo
Redis事务
单链式存储结构 插入顺序的问题
mysql_备份还原_指定表_备份表_还原表_innobackup
列表元素相加
由两个栈组成的队列
Hyperledger Fabric 超级账本 CA集群搭建使用
xshell安装完,启动报错:由于找不到 mfc110.dll,无法继续执行代码。重新安装程序可能会解决此问题
Deployment of Dameng DEM
Flink DataStream API (十四)Flink 输出到 MySQL(JDBC)
【深度学习】卷积神经网络最大池化运算
mysql_主从同步_show slave status详解
CDH安装中Mysql配置
Basic architecture of data warehouse -- layered functions
查询学生成绩在80之上的学生信息