当前位置:   article > 正文

PyQT——蓝牙收发数据(上位机案例-小车控制器)_蓝牙上位机编写

蓝牙上位机编写
实现功能

由于本人水平有限,仅用了最简单的进行实现,主要功能

  • 蓝牙设备扫描以及刷新
  • 蓝牙连接
  • 蓝牙数据发送
  • 蓝牙数据接收
页面实现效果

代码目录结构
代码案例
  • 代码已经全部添加注释,故不再做单独解释。
Main.py 
ble_control_widget.py
  1. from PyQt5.QtWidgets import *
  2. from PyQt5.QtGui import *
  3. from PyQt5.QtCore import *
  4. import sys
  5. import threading
  6. sys.path.append('..')
  7. from ui.Ui_ble_control_widget import *
  8. from drivers.driver_bluetooth import BluetoothDataTransfer
  9. class BleControlWidget(QWidget):
  10. # 信号定义
  11. # 蓝牙列表刷新
  12. refresh_signal = pyqtSignal()
  13. receive_data_signal = pyqtSignal(bytes)
  14. update_connection_signal = pyqtSignal()
  15. def __init__(self, parent=None):
  16. super().__init__(parent)
  17. self.ui = Ui_BleControlWidget()
  18. self.ui.setupUi(self)
  19. # 按钮槽函数调用
  20. self.init_ui()
  21. # 实例化属性便于全局调用
  22. self.device_list = [] # 蓝牙设备列表
  23. self.bd = None
  24. # 进入界面默认调用
  25. # 刷新蓝牙列表
  26. self.refreshBtn_subthread()
  27. def init_ui(self):
  28. '''按钮与槽函数连接'''
  29. # 刷新按钮槽函数绑定
  30. self.ui.refreshBtn.clicked.connect(self.refreshBtn_slot)
  31. # 连接蓝牙槽函数绑定
  32. self.ui.connectBtn.clicked.connect(self.connectBtn_slot)
  33. # 蓝牙列表更新信号与槽函数连接
  34. self.refresh_signal.connect(self.refresh_signal_slot)
  35. # 接收到的数据展示信号与槽函数连接
  36. self.receive_data_signal.connect(self.receive_data_signal_slot)
  37. # 更新蓝牙的状态槽函数绑定
  38. self.update_connection_signal.connect(self.update_connection_signal_slot)
  39. # 各控制按钮槽函数绑定
  40. self.ui.buzzerOnBtn.clicked.connect(self.contorl_btn_slot)
  41. self.ui.distanceBtn.clicked.connect(self.contorl_btn_slot)
  42. self.ui.downBtn.clicked.connect(self.contorl_btn_slot)
  43. self.ui.leftBtn.clicked.connect(self.contorl_btn_slot)
  44. self.ui.lightOffBtn.clicked.connect(self.contorl_btn_slot)
  45. self.ui.lightOnBtn.clicked.connect(self.contorl_btn_slot)
  46. self.ui.rightBtn.clicked.connect(self.contorl_btn_slot)
  47. self.ui.rotateBtn.clicked.connect(self.contorl_btn_slot)
  48. self.ui.stopBtn.clicked.connect(self.contorl_btn_slot)
  49. self.ui.trackOffBtn.clicked.connect(self.contorl_btn_slot)
  50. self.ui.trackOnBtn.clicked.connect(self.contorl_btn_slot)
  51. self.ui.upBtn.clicked.connect(self.contorl_btn_slot)
  52. def contorl_btn_slot(self):
  53. if not self.bp:
  54. QMessageBox.warning(self, "蓝牙未连接", "请先连接蓝牙")
  55. return
  56. sender = self.sender()
  57. if sender is self.ui.buzzerOnBtn:
  58. res,msg = self.bd.send_data(b"\x01")
  59. elif sender is self.ui.distanceBtn:
  60. res,msg = self.bd.send_data(b"\x02")
  61. elif sender is self.ui.downBtn:
  62. res,msg = self.bd.send_data(b"\x03")
  63. elif sender is self.ui.leftBtn:
  64. res,msg = self.bd.send_data(b"\x04")
  65. elif sender is self.ui.lightOffBtn:
  66. res,msg = self.bd.send_data(b"\x05")
  67. elif sender is self.ui.lightOnBtn:
  68. res,msg = self.bd.send_data(b"\x06")
  69. elif sender is self.ui.rightBtn:
  70. res,msg = self.bd.send_data(b"\x07")
  71. elif sender is self.ui.rotateBtn:
  72. res,msg = self.bd.send_data(b"\x08")
  73. elif sender is self.ui.stopBtn:
  74. res,msg = self.bd.send_data(b"\x09")
  75. elif sender is self.ui.trackOffBtn:
  76. res,msg = self.bd.send_data(b"\x0a")
  77. elif sender is self.ui.trackOnBtn:
  78. res,msg = self.bd.send_data(b"\x0b")
  79. elif sender is self.ui.upBtn:
  80. res,msg = self.bd.send_data(b"\x0c")
  81. if res:
  82. QMessageBox.information(self, '提示', msg)
  83. else:
  84. QMessageBox.warning(self, '警告', msg)
  85. def update_connection_signal_slot(self):
  86. self.ui.connectBtn.setText("已连接")
  87. self.ui.connectBtn.setIcon(QIcon(":/icon/disc"))
  88. def receive_data_signal_slot(self, data):
  89. QMessageBox.information(self, '提示', f'接收到数据:{data}')
  90. def refresh_signal_slot(self):
  91. if len(self.device_list)>0:
  92. for addr,bluetooth in self.device_list:
  93. self.ui.comboBox.addItem(bluetooth)
  94. def refreshBtn_slot(self):
  95. # 如果在刷新前有数据,清空下拉列表,否则会增加多倍数据在下拉框中导致索引超出
  96. if self.device_list:
  97. self.ui.comboBox.clear()
  98. self.device_list = []
  99. '''刷新按钮槽函数定义'''
  100. # 刷新很耗时间,需要开子线程处理,否则页面卡死
  101. t = threading.Thread(target=self.refreshBtn_subthread,daemon=True)
  102. t.start()
  103. def refreshBtn_subthread(self):
  104. '''搜索蓝牙并展示在选择下拉列表中'''
  105. self.device_list = BluetoothDataTransfer.scan_devices()
  106. # 展示在下拉列表中需要用到信号,子线程中无法直接更新ui页面,会报错
  107. print(self.device_list)
  108. # 发送信号
  109. self.refresh_signal.emit()
  110. def connectBtn_slot(self):
  111. if self.bd:
  112. self.bd.disconnect()
  113. self.bd = []
  114. self.ui.connectBtn.setText("连接蓝牙")
  115. self.ui.connectBtn.setIcon(QIcon(":/icon/connect"))
  116. return
  117. '''连接蓝牙按钮槽函数定义'''
  118. # 连接很耗时间,需要开子线程处理,否则页面卡死
  119. t = threading.Thread(target=self.connectBtn_subthread,daemon=True)
  120. t.start()
  121. def connectBtn_subthread(self):
  122. # 获取蓝牙选项
  123. index = self.ui.comboBox.currentIndex()
  124. address = self.device_list[index][0]
  125. name = self.ui.comboBox.currentText()
  126. # 连接蓝牙
  127. self.bd = BluetoothDataTransfer(address, name) # 替换为目标设备的蓝牙地址和端口号
  128. flag = self.bd.connect()
  129. print(flag)
  130. if not flag:
  131. return
  132. # 更新蓝牙连接状态文字和图标
  133. self.update_connection_signal.emit()
  134. # 开始接受数据
  135. while True:
  136. data = self.bd.receive_data(1024)
  137. if data:
  138. # 发送数据到页面弹窗显示
  139. print(data)
  140. #self.receive_data_signal.emit(data)
  141. if __name__ == '__main__':
  142. app = QApplication(sys.argv)
  143. widget = BleControlWidget()
  144. widget.show()
  145. sys.exit(app.exec_())
driver_bluetooth.py(来自开源工具)
  1. import bluetooth
  2. # 扫描所有设备
  3. class BluetoothDataTransfer:
  4. def __init__(self, target_address, target_name, port=1):
  5. self.target_address = target_address
  6. self.target_name = target_name
  7. self.port = port
  8. self.socket = None
  9. def connect(self):
  10. """
  11. 连接蓝牙设备
  12. :return:
  13. """
  14. try:
  15. self.socket = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
  16. self.socket.connect((self.target_address, self.port))
  17. print("Connected successfully. {} ({})".format(
  18. self.target_name, self.target_address
  19. ))
  20. return True
  21. except (bluetooth.BluetoothError, OSError) as e:
  22. self.socket = None
  23. print("Connection failed:", str(e))
  24. return False
  25. def disconnect(self):
  26. """
  27. 断开蓝牙连接
  28. :return:
  29. """
  30. if self.socket is not None:
  31. self.socket.close()
  32. print("Disconnected.")
  33. def send_data(self, data):
  34. """
  35. 发送数据
  36. :param data:
  37. :return:
  38. """
  39. if self.socket is not None:
  40. try:
  41. self.socket.send(data)
  42. print("Data sent:", data)
  43. return True,"sent succeed"
  44. except bluetooth.BluetoothError as e:
  45. print("Failed to send data:", str(e))
  46. return False,str(e)
  47. else:
  48. print("Not connected.")
  49. return False,"Not connected."
  50. def receive_data(self, buffer_size=2048):
  51. """
  52. 接收数据
  53. :param buffer_size:
  54. :return:
  55. """
  56. if self.socket is None:
  57. print("Not connected.")
  58. return
  59. try:
  60. data = self.socket.recv(buffer_size)
  61. # print("Data received:", data.decode())
  62. return data
  63. except bluetooth.BluetoothError as e:
  64. print("Failed to receive data:", str(e))
  65. @staticmethod
  66. def scan_devices():
  67. """
  68. 扫描所有蓝牙设备
  69. :return:
  70. """
  71. devices = bluetooth.discover_devices()
  72. print("Scanning devices...")
  73. device_list = []
  74. for addr in devices:
  75. name = bluetooth.lookup_name(addr)
  76. print("Found device:", name, "(", addr, ")")
  77. device_list.append((addr, name))
  78. return device_list
  79. if __name__ == '__main__':
  80. # print("=========================================开始扫描")
  81. # devices = BluetoothDataTransfer.scan_devices()
  82. # for device in devices:
  83. # print(device)
  84. # print("=========================================结束扫描")
  85. # 示例用法
  86. bd = BluetoothDataTransfer("FA:34:0A:92:71:42", 'JDY-33-SPP-kkkkkkk') # 替换为目标设备的蓝牙地址和端口号
  87. flag = bd.connect()
  88. print(flag)
  89. if flag:
  90. # bd.send_data("Hello, Bluetooth!") # 发送数据
  91. bd.send_data(b"\x12") # 发送数据
  92. recv_data = bd.receive_data() # 接收数据
  93. print("接收到的数据:", recv_data)
  94. bd.disconnect()
Ui_ble_control_widget.py(由QT页面编译而成)
  1. # -*- coding: utf-8 -*-
  2. # Form implementation generated from reading ui file 'c:\Users\Windows10\Desktop\02上课代码步骤\小车实战 copy\ui\ble_control_widget.ui'
  3. #
  4. # Created by: PyQt5 UI code generator 5.15.9
  5. #
  6. # WARNING: Any manual changes made to this file will be lost when pyuic5 is
  7. # run again. Do not edit this file unless you know what you are doing.
  8. from PyQt5 import QtCore, QtGui, QtWidgets
  9. class Ui_BleControlWidget(object):
  10. def setupUi(self, BleControlWidget):
  11. BleControlWidget.setObjectName("BleControlWidget")
  12. BleControlWidget.resize(411, 276)
  13. self.verticalLayout_2 = QtWidgets.QVBoxLayout(BleControlWidget)
  14. self.verticalLayout_2.setObjectName("verticalLayout_2")
  15. self.setLayout = QtWidgets.QHBoxLayout()
  16. self.setLayout.setObjectName("setLayout")
  17. self.label = QtWidgets.QLabel(BleControlWidget)
  18. font = QtGui.QFont()
  19. font.setFamily("Agency FB")
  20. font.setPointSize(10)
  21. font.setBold(True)
  22. font.setWeight(75)
  23. self.label.setFont(font)
  24. self.label.setObjectName("label")
  25. self.setLayout.addWidget(self.label)
  26. self.comboBox = QtWidgets.QComboBox(BleControlWidget)
  27. sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed)
  28. sizePolicy.setHorizontalStretch(0)
  29. sizePolicy.setVerticalStretch(0)
  30. sizePolicy.setHeightForWidth(self.comboBox.sizePolicy().hasHeightForWidth())
  31. self.comboBox.setSizePolicy(sizePolicy)
  32. self.comboBox.setMinimumSize(QtCore.QSize(0, 25))
  33. self.comboBox.setObjectName("comboBox")
  34. self.setLayout.addWidget(self.comboBox)
  35. self.refreshBtn = QtWidgets.QPushButton(BleControlWidget)
  36. self.refreshBtn.setText("")
  37. icon = QtGui.QIcon()
  38. icon.addPixmap(QtGui.QPixmap(":/icon/refresh"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  39. self.refreshBtn.setIcon(icon)
  40. self.refreshBtn.setFlat(True)
  41. self.refreshBtn.setObjectName("refreshBtn")
  42. self.setLayout.addWidget(self.refreshBtn)
  43. self.connectBtn = QtWidgets.QPushButton(BleControlWidget)
  44. icon1 = QtGui.QIcon()
  45. icon1.addPixmap(QtGui.QPixmap(":/icon/connect"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  46. self.connectBtn.setIcon(icon1)
  47. self.connectBtn.setObjectName("connectBtn")
  48. self.setLayout.addWidget(self.connectBtn)
  49. self.setLayout.setStretch(0, 1)
  50. self.setLayout.setStretch(1, 4)
  51. self.setLayout.setStretch(2, 1)
  52. self.setLayout.setStretch(3, 2)
  53. self.verticalLayout_2.addLayout(self.setLayout)
  54. self.frame = QtWidgets.QFrame(BleControlWidget)
  55. self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
  56. self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
  57. self.frame.setObjectName("frame")
  58. self.verticalLayout = QtWidgets.QVBoxLayout(self.frame)
  59. self.verticalLayout.setContentsMargins(0, 0, 0, 0)
  60. self.verticalLayout.setSpacing(0)
  61. self.verticalLayout.setObjectName("verticalLayout")
  62. self.btnLayout = QtWidgets.QGridLayout()
  63. self.btnLayout.setSpacing(10)
  64. self.btnLayout.setObjectName("btnLayout")
  65. self.lightOnBtn = QtWidgets.QPushButton(self.frame)
  66. sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
  67. sizePolicy.setHorizontalStretch(0)
  68. sizePolicy.setVerticalStretch(0)
  69. sizePolicy.setHeightForWidth(self.lightOnBtn.sizePolicy().hasHeightForWidth())
  70. self.lightOnBtn.setSizePolicy(sizePolicy)
  71. font = QtGui.QFont()
  72. font.setFamily("Agency FB")
  73. font.setPointSize(22)
  74. self.lightOnBtn.setFont(font)
  75. self.lightOnBtn.setObjectName("lightOnBtn")
  76. self.btnLayout.addWidget(self.lightOnBtn, 4, 0, 1, 1)
  77. self.upBtn = QtWidgets.QPushButton(self.frame)
  78. sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
  79. sizePolicy.setHorizontalStretch(0)
  80. sizePolicy.setVerticalStretch(0)
  81. sizePolicy.setHeightForWidth(self.upBtn.sizePolicy().hasHeightForWidth())
  82. self.upBtn.setSizePolicy(sizePolicy)
  83. font = QtGui.QFont()
  84. font.setFamily("Agency FB")
  85. font.setPointSize(22)
  86. self.upBtn.setFont(font)
  87. self.upBtn.setObjectName("upBtn")
  88. self.btnLayout.addWidget(self.upBtn, 0, 1, 1, 1)
  89. self.stopBtn = QtWidgets.QPushButton(self.frame)
  90. sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
  91. sizePolicy.setHorizontalStretch(0)
  92. sizePolicy.setVerticalStretch(0)
  93. sizePolicy.setHeightForWidth(self.stopBtn.sizePolicy().hasHeightForWidth())
  94. self.stopBtn.setSizePolicy(sizePolicy)
  95. font = QtGui.QFont()
  96. font.setFamily("Agency FB")
  97. font.setPointSize(22)
  98. self.stopBtn.setFont(font)
  99. self.stopBtn.setObjectName("stopBtn")
  100. self.btnLayout.addWidget(self.stopBtn, 2, 1, 1, 1)
  101. self.leftBtn = QtWidgets.QPushButton(self.frame)
  102. sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
  103. sizePolicy.setHorizontalStretch(0)
  104. sizePolicy.setVerticalStretch(0)
  105. sizePolicy.setHeightForWidth(self.leftBtn.sizePolicy().hasHeightForWidth())
  106. self.leftBtn.setSizePolicy(sizePolicy)
  107. font = QtGui.QFont()
  108. font.setFamily("Agency FB")
  109. font.setPointSize(22)
  110. self.leftBtn.setFont(font)
  111. self.leftBtn.setObjectName("leftBtn")
  112. self.btnLayout.addWidget(self.leftBtn, 2, 0, 1, 1)
  113. self.rotateBtn = QtWidgets.QPushButton(self.frame)
  114. sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
  115. sizePolicy.setHorizontalStretch(0)
  116. sizePolicy.setVerticalStretch(0)
  117. sizePolicy.setHeightForWidth(self.rotateBtn.sizePolicy().hasHeightForWidth())
  118. self.rotateBtn.setSizePolicy(sizePolicy)
  119. font = QtGui.QFont()
  120. font.setFamily("Agency FB")
  121. font.setPointSize(22)
  122. self.rotateBtn.setFont(font)
  123. self.rotateBtn.setObjectName("rotateBtn")
  124. self.btnLayout.addWidget(self.rotateBtn, 5, 1, 1, 1)
  125. self.downBtn = QtWidgets.QPushButton(self.frame)
  126. sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
  127. sizePolicy.setHorizontalStretch(0)
  128. sizePolicy.setVerticalStretch(0)
  129. sizePolicy.setHeightForWidth(self.downBtn.sizePolicy().hasHeightForWidth())
  130. self.downBtn.setSizePolicy(sizePolicy)
  131. font = QtGui.QFont()
  132. font.setFamily("Agency FB")
  133. font.setPointSize(22)
  134. self.downBtn.setFont(font)
  135. self.downBtn.setObjectName("downBtn")
  136. self.btnLayout.addWidget(self.downBtn, 4, 1, 1, 1)
  137. self.lightOffBtn = QtWidgets.QPushButton(self.frame)
  138. sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
  139. sizePolicy.setHorizontalStretch(0)
  140. sizePolicy.setVerticalStretch(0)
  141. sizePolicy.setHeightForWidth(self.lightOffBtn.sizePolicy().hasHeightForWidth())
  142. self.lightOffBtn.setSizePolicy(sizePolicy)
  143. font = QtGui.QFont()
  144. font.setFamily("Agency FB")
  145. font.setPointSize(22)
  146. self.lightOffBtn.setFont(font)
  147. self.lightOffBtn.setObjectName("lightOffBtn")
  148. self.btnLayout.addWidget(self.lightOffBtn, 4, 2, 1, 1)
  149. self.trackOffBtn = QtWidgets.QPushButton(self.frame)
  150. sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
  151. sizePolicy.setHorizontalStretch(0)
  152. sizePolicy.setVerticalStretch(0)
  153. sizePolicy.setHeightForWidth(self.trackOffBtn.sizePolicy().hasHeightForWidth())
  154. self.trackOffBtn.setSizePolicy(sizePolicy)
  155. font = QtGui.QFont()
  156. font.setFamily("Agency FB")
  157. font.setPointSize(22)
  158. self.trackOffBtn.setFont(font)
  159. self.trackOffBtn.setObjectName("trackOffBtn")
  160. self.btnLayout.addWidget(self.trackOffBtn, 5, 2, 1, 1)
  161. self.trackOnBtn = QtWidgets.QPushButton(self.frame)
  162. sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
  163. sizePolicy.setHorizontalStretch(0)
  164. sizePolicy.setVerticalStretch(0)
  165. sizePolicy.setHeightForWidth(self.trackOnBtn.sizePolicy().hasHeightForWidth())
  166. self.trackOnBtn.setSizePolicy(sizePolicy)
  167. font = QtGui.QFont()
  168. font.setFamily("Agency FB")
  169. font.setPointSize(22)
  170. self.trackOnBtn.setFont(font)
  171. self.trackOnBtn.setObjectName("trackOnBtn")
  172. self.btnLayout.addWidget(self.trackOnBtn, 5, 0, 1, 1)
  173. self.rightBtn = QtWidgets.QPushButton(self.frame)
  174. sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
  175. sizePolicy.setHorizontalStretch(0)
  176. sizePolicy.setVerticalStretch(0)
  177. sizePolicy.setHeightForWidth(self.rightBtn.sizePolicy().hasHeightForWidth())
  178. self.rightBtn.setSizePolicy(sizePolicy)
  179. font = QtGui.QFont()
  180. font.setFamily("Agency FB")
  181. font.setPointSize(22)
  182. self.rightBtn.setFont(font)
  183. self.rightBtn.setObjectName("rightBtn")
  184. self.btnLayout.addWidget(self.rightBtn, 2, 2, 1, 1)
  185. self.distanceBtn = QtWidgets.QPushButton(self.frame)
  186. sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
  187. sizePolicy.setHorizontalStretch(0)
  188. sizePolicy.setVerticalStretch(0)
  189. sizePolicy.setHeightForWidth(self.distanceBtn.sizePolicy().hasHeightForWidth())
  190. self.distanceBtn.setSizePolicy(sizePolicy)
  191. font = QtGui.QFont()
  192. font.setFamily("Agency FB")
  193. font.setPointSize(22)
  194. self.distanceBtn.setFont(font)
  195. self.distanceBtn.setObjectName("distanceBtn")
  196. self.btnLayout.addWidget(self.distanceBtn, 0, 2, 1, 1)
  197. self.buzzerOnBtn = QtWidgets.QPushButton(self.frame)
  198. sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
  199. sizePolicy.setHorizontalStretch(0)
  200. sizePolicy.setVerticalStretch(0)
  201. sizePolicy.setHeightForWidth(self.buzzerOnBtn.sizePolicy().hasHeightForWidth())
  202. self.buzzerOnBtn.setSizePolicy(sizePolicy)
  203. font = QtGui.QFont()
  204. font.setFamily("Agency FB")
  205. font.setPointSize(22)
  206. self.buzzerOnBtn.setFont(font)
  207. self.buzzerOnBtn.setObjectName("buzzerOnBtn")
  208. self.btnLayout.addWidget(self.buzzerOnBtn, 0, 0, 1, 1)
  209. self.verticalLayout.addLayout(self.btnLayout)
  210. self.verticalLayout_2.addWidget(self.frame)
  211. self.verticalLayout_2.setStretch(0, 1)
  212. self.verticalLayout_2.setStretch(1, 3)
  213. self.retranslateUi(BleControlWidget)
  214. QtCore.QMetaObject.connectSlotsByName(BleControlWidget)
  215. def retranslateUi(self, BleControlWidget):
  216. _translate = QtCore.QCoreApplication.translate
  217. BleControlWidget.setWindowTitle(_translate("BleControlWidget", "小车蓝牙控制器"))
  218. self.label.setText(_translate("BleControlWidget", "蓝牙选择:"))
  219. self.connectBtn.setText(_translate("BleControlWidget", "连接蓝牙"))
  220. self.lightOnBtn.setText(_translate("BleControlWidget", "开灯"))
  221. self.upBtn.setText(_translate("BleControlWidget", "上"))
  222. self.stopBtn.setText(_translate("BleControlWidget", "停止"))
  223. self.leftBtn.setText(_translate("BleControlWidget", "左"))
  224. self.rotateBtn.setText(_translate("BleControlWidget", "旋转"))
  225. self.downBtn.setText(_translate("BleControlWidget", "下"))
  226. self.lightOffBtn.setText(_translate("BleControlWidget", "关灯"))
  227. self.trackOffBtn.setText(_translate("BleControlWidget", "关寻迹"))
  228. self.trackOnBtn.setText(_translate("BleControlWidget", "开寻迹"))
  229. self.rightBtn.setText(_translate("BleControlWidget", "右"))
  230. self.distanceBtn.setText(_translate("BleControlWidget", "测距"))
  231. self.buzzerOnBtn.setText(_translate("BleControlWidget", "开喇叭"))
  232. from ui import resource_rc
声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号