测试了密胺的整个流程、add(点位设置界面增加了 停止功能按钮)、fix bug(修复了点位名称写入数据库不一致的错误)

This commit is contained in:
2025-09-28 17:55:32 +08:00
parent 80272b92b4
commit faea225e24
16 changed files with 10403 additions and 154 deletions

View File

@ -324,7 +324,7 @@ class FormDatabase:
row[4], # 6. rx
row[5], # 7. ry
row[6], # 8. rz
pos_name, # 9. name # 以点位状态中的 pos_name 为准
row[7], # 9. name # 以表格中的 name 为准
speed, # 10. speed
tool_id, # 11. tool_id
workpiece_id, # 12. workpiece_id
@ -606,8 +606,12 @@ class CoordinateTableWidget(QWidget):
# 选中行更新信号
update_table_signal = Signal()
# 移动到选中行的 坐标的信号
move_to_coodinate_signal = Signal(list)
# 移动到选中行的 坐标的信号 (保证了发送的一定是合法坐标)
# 坐标列表 和 相应的点位名字列表
move_to_coodinate_signal = Signal(list, list)
# 机器停止信号,机器臂停止移动
machine_stop_signal = Signal()
def __init__(
self, parent=None, form_name="default", hideVHeader=False, initRowCount=True
@ -639,6 +643,7 @@ class CoordinateTableWidget(QWidget):
# 状态标签
self.status_label = QLabel("未选中任何行")
self.status_label.setWordWrap(True) # 启用自动换行
self.mainLayout.addWidget(self.status_label)
# 应用主题样式
@ -695,7 +700,8 @@ class CoordinateTableWidget(QWidget):
self.mainLayout.addWidget(self.table, stretch=1)
def createButtons(self):
btnLayout = QHBoxLayout()
# =========第一行按钮布局===========
btnLayout = QHBoxLayout()
btnLayout.setSpacing(15)
self.addBtn = PushButton("添加行")
@ -720,32 +726,45 @@ class CoordinateTableWidget(QWidget):
self.readBtn.clicked.connect(self.moveToSelectedCoodinate)
btnLayout.addWidget(self.readBtn)
# 保存按钮
self.saveBtn = PushButton("保存数据")
self.saveBtn.setIcon(FIF.SAVE.icon()) # 使用保存图标
self.saveBtn.clicked.connect(self.saveToDatabase) # 关联保存函数
btnLayout.addWidget(self.saveBtn)
self.machineStopBtn = PushButton("机器停止")
self.machineStopBtn.setIcon(FIF.PAUSE.icon())
self.machineStopBtn.clicked.connect(self.machine_stop_signal)
btnLayout.addWidget(self.machineStopBtn)
btnLayout2 = QHBoxLayout()
btnLayout2.setSpacing(15)
# ==============第二行按钮布局==================
bottomBtnLayout = QHBoxLayout()
bottomBtnLayout.setSpacing(15)
# 上移按钮
# 1. 上移 + 下移
moveComboLayout = QHBoxLayout()
moveComboLayout.setSpacing(15) # 组合内按钮间距
self.moveUpBtn = PushButton("上移")
self.moveUpBtn.clicked.connect(self.moveRowUp)
btnLayout2.addWidget(self.moveUpBtn)
# 下移按钮
moveComboLayout.addWidget(self.moveUpBtn)
self.moveDownBtn = PushButton("下移")
self.moveDownBtn.clicked.connect(self.moveRowDown)
btnLayout2.addWidget(self.moveDownBtn)
moveComboLayout.addWidget(self.moveDownBtn)
bottomBtnLayout.addLayout(moveComboLayout)
# 状态编辑按钮
# 2. 状态编辑 + 默认状态
stateComboLayout = QHBoxLayout()
stateComboLayout.setSpacing(15)
self.stateEditBtn = PushButton("状态编辑")
self.stateEditBtn.clicked.connect(self.onStateEdit)
btnLayout2.addWidget(self.stateEditBtn)
stateComboLayout.addWidget(self.stateEditBtn)
self.defaultStateBtn = PushButton("默认状态")
# self.defaultStateBtn.clicked.connect(self.onDefaultState) # 需实现默认状态逻辑
stateComboLayout.addWidget(self.defaultStateBtn)
bottomBtnLayout.addLayout(stateComboLayout)
# 3. 保存数据 按钮
self.saveDataBtn = PushButton("保存数据")
self.saveDataBtn.setIcon(FIF.SAVE.icon())
self.saveDataBtn.clicked.connect(self.saveToDatabase)
bottomBtnLayout.addWidget(self.saveDataBtn)
self.mainLayout.addLayout(btnLayout) # 添加 按钮布局一
self.mainLayout.addLayout(btnLayout2) # 添加 按钮布局二
self.mainLayout.addLayout(bottomBtnLayout) # 添加 按钮布局二
# 数据保存到数据库,获取数据时调用
def get_ui_data(self):
@ -1011,9 +1030,14 @@ class CoordinateTableWidget(QWidget):
# 得到选中行的 点位(坐标) 列表,然后发送
sortedRowIdList = sorted(selectedRows) # 将选中行的行索引进行排序
coordinate_rows = list()
coordinate_rows = list() # 多行的坐标
name_rows = list() # 多行的名字
for row_idx in sortedRowIdList:
row_coordinate = list() # 保存这一行的坐标
for col_idx in range(6): # 0-5 ,这些列为坐标 x, y, z, rx, ry, rz
item = self.table.item(row_idx, col_idx)
@ -1041,8 +1065,15 @@ class CoordinateTableWidget(QWidget):
# 最终结果:[[x1, y1, z1, rx1, ry1, rz1], ......]
# x1等都为浮点类型
coordinate_rows.append(row_coordinate)
# 发送移动到这些坐标的信号
self.move_to_coodinate_signal.emit(coordinate_rows)
# ========== 9/17 新增: 点位的名字 移动时携带点位名=====
name_col_idx = 6 # 名字的列索引为6
name_item = self.table.item(row_idx, name_col_idx)
cood_name = name_item.text().strip() # 坐标/点位 的名字
name_rows.append(cood_name)
# 发送移动到这些 坐标 和 名字 的信号
self.move_to_coodinate_signal.emit(coordinate_rows, name_rows)
# 保存数据
def saveToDatabase(self):
@ -1330,7 +1361,11 @@ class CoordinateFormsWidget(QWidget):
form_update_signal = Signal(CoordinateTableWidget)
# 表单中 移动到坐标的信号 (用于机器臂的移动)
form_move_signal = Signal(list)
# 点位列表 和 名字列表
form_move_signal = Signal(list, list)
# 表单中 机器臂停止移动信号
form_machine_stop_signal = Signal()
def __init__(self, parent=None):
super().__init__(parent)
@ -1440,9 +1475,7 @@ class CoordinateFormsWidget(QWidget):
formKey = f"form_{self.formTotalCnt}" # 唯一标识, form_1
# 创建表单实例时传入表单名
newForm = CoordinateTableWidget(form_name=firstFormName, parent=self)
newForm.update_table_signal.connect(self.handleFormUpdate)
newForm.move_to_coodinate_signal.connect(self.form_move_signal)
newForm = self.createNewFormInstance(firstFormName)
self.tabBar.addTab(routeKey=formKey, text=firstFormName, icon=FIF.TILES.icon())
self.formStack.addWidget(newForm)
@ -1474,9 +1507,7 @@ class CoordinateFormsWidget(QWidget):
formKey = f"form_{self.formTotalCnt}" # 唯一标识
# 创建表单实例时传入表单名
newForm = CoordinateTableWidget(form_name=formName, parent=self)
newForm.update_table_signal.connect(self.handleFormUpdate)
newForm.move_to_coodinate_signal.connect(self.form_move_signal)
newForm = self.createNewFormInstance(formName)
self.tabBar.addTab(routeKey=formKey, text=formName, icon=FIF.TILES.icon())
self.formStack.addWidget(newForm)
@ -1502,6 +1533,15 @@ class CoordinateFormsWidget(QWidget):
self.formStack.removeWidget(formToRemove)
formToRemove.deleteLater()
# 创建并返回一个表单实例
def createNewFormInstance(self, formName:str, hideVHeader=False, initRowCount=True):
newForm = CoordinateTableWidget(form_name=formName, parent=self, hideVHeader=hideVHeader, initRowCount=initRowCount)
newForm.update_table_signal.connect(self.handleFormUpdate)
newForm.move_to_coodinate_signal.connect(self.form_move_signal)
newForm.machine_stop_signal.connect(self.form_machine_stop_signal)
return newForm
def switchForm(self, index):
if 0 <= index < self.formStack.count():
self.formStack.setCurrentIndex(index)
@ -1737,11 +1777,7 @@ class CoordinateFormsWidget(QWidget):
for form_name, data_rows in form_data.items():
# 创建新表单
self.formTotalCnt += 1 # 创建的总的表单数加一
new_form = CoordinateTableWidget(
form_name=f"{form_name}", parent=self, initRowCount=False
)
new_form.update_table_signal.connect(self.handleFormUpdate)
new_form.move_to_coodinate_signal.connect(self.form_move_signal)
new_form = self.createNewFormInstance(formName=form_name, initRowCount=False)
# 填充数据到新表单(包含点位名)
for row_idx, x, y, z, rx, ry, rz, name, pos_state_dict in data_rows:

View File

@ -64,7 +64,7 @@ class Window(FramelessWindow):
self.setTitleBar(StandardTitleBar(self))
# use dark theme mode
# setTheme(Theme.DARK)
setTheme(Theme.DARK)
# change the theme color
# setThemeColor('#0078d4')
@ -226,13 +226,8 @@ class Window(FramelessWindow):
QDesktopServices.openUrl(QUrl("https://afdian.net/a/zhiyiYo"))
def move_test(pos_list: list):
print("移动:", pos_list)
# if __name__ == "__main__":
# app = QApplication([])
# w = Window()
# w.position.formsWidget.form_move_signal.connect(move_test)
# w.show()
# app.exec()
if __name__ == "__main__":
app = QApplication([])
w = Window()
w.show()
app.exec()

View File

@ -1,48 +1,77 @@
# coding:utf-8
from PySide6.QtCore import Qt, QEasingCurve, QTimer
from PySide6.QtGui import QColor, QImage, QPixmap
from PySide6.QtWidgets import QWidget, QStackedWidget, QVBoxLayout, QLabel, QHBoxLayout, QFrame, QSizePolicy
from qfluentwidgets import (Pivot, qrouter, SegmentedWidget, TabBar, CheckBox, ComboBox,
TabCloseButtonDisplayMode, BodyLabel, SpinBox, BreadcrumbBar,
SegmentedToggleToolWidget, FluentIcon, TransparentPushButton, EditableComboBox, PrimaryPushButton, Slider, DisplayLabel, TextBrowser, SwitchButton, PillPushButton, ToggleButton)
from PySide6.QtWidgets import (
QWidget,
QStackedWidget,
QVBoxLayout,
QLabel,
QHBoxLayout,
QFrame,
QSizePolicy,
)
from qfluentwidgets import (
Pivot,
qrouter,
SegmentedWidget,
TabBar,
CheckBox,
ComboBox,
TabCloseButtonDisplayMode,
BodyLabel,
SpinBox,
BreadcrumbBar,
SegmentedToggleToolWidget,
FluentIcon,
TransparentPushButton,
EditableComboBox,
PrimaryPushButton,
Slider,
DisplayLabel,
TextBrowser,
SwitchButton,
PillPushButton,
ToggleButton,
)
from .gallery_interface import GalleryInterface
from ..common.translator import Translator
from ..common.style_sheet import StyleSheet
import cv2
class SystemInterface(GalleryInterface):
""" Navigation view interface """
"""Navigation view interface"""
def __init__(self, parent=None):
t = Translator()
super().__init__(
title=t.navigation,
subtitle="qfluentwidgets.components.navigation",
parent=parent
parent=parent,
)
self.setObjectName('systemInterface')
self.setObjectName("systemInterface")
# breadcrumb bar
card = self.addExampleCard(
title=self.tr(''),
title=self.tr(""),
widget=TabInterface(self),
sourcePath='https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/PySide6/examples/navigation/tab_view/demo.py',
stretch=1
sourcePath="https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/PySide6/examples/navigation/tab_view/demo.py",
stretch=1,
)
card.topLayout.setContentsMargins(12, 0, 0, 0)
def createToggleToolWidget(self):
w = SegmentedToggleToolWidget(self)
w.addItem('k1', FluentIcon.TRANSPARENT)
w.addItem('k2', FluentIcon.CHECKBOX)
w.addItem('k3', FluentIcon.CONSTRACT)
w.setCurrentItem('k1')
w.addItem("k1", FluentIcon.TRANSPARENT)
w.addItem("k2", FluentIcon.CHECKBOX)
w.addItem("k3", FluentIcon.CONSTRACT)
w.setCurrentItem("k1")
return w
class TabInterface(QWidget):
""" Tab interface """
"""Tab interface"""
def __init__(self, parent=None):
super().__init__(parent=parent)
@ -53,12 +82,14 @@ class TabInterface(QWidget):
self.tabView = QWidget(self)
self.controlPanel = QFrame(self)
#clock
self.clock=TransparentPushButton("2025-08-04 16:55", self, FluentIcon.DATE_TIME)
# clock
self.clock = TransparentPushButton(
"2025-08-04 16:55", self, FluentIcon.DATE_TIME
)
# combo box
self.comboBox1 = ComboBox()
self.comboBox1.addItems(['反应釜1', '反应釜2'])
self.comboBox1.addItems(["反应釜1", "反应釜2"])
self.comboBox1.setCurrentIndex(0)
self.comboBox1.setMinimumWidth(180)
@ -67,59 +98,61 @@ class TabInterface(QWidget):
# editable combo box
self.comboBox = EditableComboBox()
self.comboBox.addItems([
"10",
"20",
"30",
"40",
"50",
"60",
"70",
"80",
])
self.comboBox.addItems(
[
"10",
"20",
"30",
"40",
"50",
"60",
"70",
"80",
]
)
self.comboBox.setPlaceholderText("自定义数量")
self.comboBox.setMinimumWidth(90)
#hBoxLayout
# hBoxLayout
self.container1 = QWidget()
self.hBoxLayout1 = QHBoxLayout(self.container1)
self.hBoxLayout1.addWidget(self.label)
self.hBoxLayout1.addWidget(self.comboBox)
#button
self.primaryButton1 = PrimaryPushButton(FluentIcon.PLAY, '启动', self)
self.primaryButton2 = PrimaryPushButton(FluentIcon.PAUSE, '暂停', self)
self.primaryButton3 = PrimaryPushButton(FluentIcon.POWER_BUTTON, '停止', self)
self.primaryButton4 = PrimaryPushButton(FluentIcon.ROTATE, '复位', self)
self.primaryButton5 = PrimaryPushButton(FluentIcon.CLOSE, '急停', self)
self.primaryButton6 = PrimaryPushButton(FluentIcon.SYNC, '清除', self)
# button
self.primaryButton1 = PrimaryPushButton(FluentIcon.PLAY, "启动", self)
self.primaryButton2 = PrimaryPushButton(FluentIcon.PAUSE, "暂停", self)
self.primaryButton3 = PrimaryPushButton(FluentIcon.POWER_BUTTON, "停止", self)
self.primaryButton4 = PrimaryPushButton(FluentIcon.ROTATE, "复位", self)
self.primaryButton5 = PrimaryPushButton(FluentIcon.CLOSE, "急停", self)
self.primaryButton6 = PrimaryPushButton(FluentIcon.SYNC, "清除", self)
self.primaryButton1.setObjectName('primaryButton1')
self.primaryButton2.setObjectName('primaryButton2')
self.primaryButton3.setObjectName('primaryButton3')
self.primaryButton4.setObjectName('primaryButton4')
self.primaryButton5.setObjectName('primaryButton5')
self.primaryButton6.setObjectName('primaryButton6')
self.primaryButton1.setObjectName("primaryButton1")
self.primaryButton2.setObjectName("primaryButton2")
self.primaryButton3.setObjectName("primaryButton3")
self.primaryButton4.setObjectName("primaryButton4")
self.primaryButton5.setObjectName("primaryButton5")
self.primaryButton6.setObjectName("primaryButton6")
#hBoxLayout2
# hBoxLayout2
self.container2 = QWidget()
self.hBoxLayout2 = QHBoxLayout(self.container2)
self.hBoxLayout2.addWidget(self.primaryButton1)
self.hBoxLayout2.addWidget(self.primaryButton2)
#hBoxLayout3
# hBoxLayout3
self.container3 = QWidget()
self.hBoxLayout3 = QHBoxLayout(self.container3)
self.hBoxLayout3.addWidget(self.primaryButton3)
self.hBoxLayout3.addWidget(self.primaryButton4)
#hBoxLayout4
# hBoxLayout4
self.container4 = QWidget()
self.hBoxLayout4 = QHBoxLayout(self.container4)
self.hBoxLayout4.addWidget(self.primaryButton5)
self.hBoxLayout4.addWidget(self.primaryButton6)
#滑动条
# 滑动条
self.slider = Slider(Qt.Horizontal)
self.slider.setFixedWidth(200)
@ -130,62 +163,66 @@ class TabInterface(QWidget):
# Displaylabel
self.label2 = DisplayLabel("目标袋数")
self.label3 = DisplayLabel("0")
self.label3.setObjectName('label3')
self.label3.setObjectName("label3")
self.label3.setStyleSheet("color: red;")
self.label4 = DisplayLabel("剩余袋数")
self.label5 = DisplayLabel("0")
self.label5.setObjectName('label5')
self.label5.setObjectName("label5")
self.label5.setStyleSheet("color: green;")
#hBoxLayout
# hBoxLayout
self.container5 = QWidget()
self.hBoxLayout5 = QHBoxLayout(self.container5)
self.hBoxLayout5.addWidget(self.label2)
self.hBoxLayout5.addWidget(self.label3)
#hBoxLayout
# hBoxLayout
self.container6 = QWidget()
self.hBoxLayout6 = QHBoxLayout(self.container6)
self.hBoxLayout6.addWidget(self.label4)
self.hBoxLayout6.addWidget(self.label5)
#self.movableCheckBox = CheckBox(self.tr('IsTabMovable'), self)
#self.scrollableCheckBox = CheckBox(self.tr('IsTabScrollable'), self)
#self.shadowEnabledCheckBox = CheckBox(self.tr('IsTabShadowEnabled'), self)
#self.tabMaxWidthLabel = BodyLabel(self.tr('TabMaximumWidth'), self)
# self.movableCheckBox = CheckBox(self.tr('IsTabMovable'), self)
# self.scrollableCheckBox = CheckBox(self.tr('IsTabScrollable'), self)
# self.shadowEnabledCheckBox = CheckBox(self.tr('IsTabShadowEnabled'), self)
# self.tabMaxWidthLabel = BodyLabel(self.tr('TabMaximumWidth'), self)
# self.tabMaxWidthSpinBox = SpinBox(self)
#self.closeDisplayModeLabel = BodyLabel(self.tr('TabCloseButtonDisplayMode'), self)
#self.closeDisplayModeComboBox = ComboBox(self)
# self.closeDisplayModeLabel = BodyLabel(self.tr('TabCloseButtonDisplayMode'), self)
# self.closeDisplayModeComboBox = ComboBox(self)
self.hBoxLayout = QHBoxLayout(self)
self.vBoxLayout = QVBoxLayout(self.tabView)
self.panelLayout = QVBoxLayout(self.controlPanel)
#富文本编辑栏用来显示日志
# 富文本编辑栏用来显示日志
self.textBrowser = TextBrowser()
#self.textBrowser.setMarkdown("## Steel Ball Run \n * Johnny Joestar 🦄 \n * Gyro Zeppeli 🐴 aaa\n * aaa\n * aaa\n * aaa\n * aaa\n *")
self.textBrowser.setMarkdown("## 日志\n * 2025-08-06 09:54:24 - 🦄进入系统\n * 2025-08-06 09:54:24 - 🐴无回复\n * 2025-08-06 09:54:24 - 🦄进入系统\n * 2025-08-06 09:54:24 - 🐴无回复\n * 2025-08-06 09:54:24 - 🦄进入系统\n * 2025-08-06 09:54:24 - 🐴无回复\n * 2025-08-06 09:54:24 - 🦄进入系统\n * 2025-08-06 09:54:24 - 🐴无回复\n *")
# self.textBrowser.setMarkdown("## Steel Ball Run \n * Johnny Joestar 🦄 \n * Gyro Zeppeli 🐴 aaa\n * aaa\n * aaa\n * aaa\n * aaa\n *")
self.textBrowser.setMarkdown(
"## 日志\n * 2025-08-06 09:54:24 - 🦄进入系统\n * 2025-08-06 09:54:24 - 🐴无回复\n * 2025-08-06 09:54:24 - 🦄进入系统\n * 2025-08-06 09:54:24 - 🐴无回复\n * 2025-08-06 09:54:24 - 🦄进入系统\n * 2025-08-06 09:54:24 - 🐴无回复\n * 2025-08-06 09:54:24 - 🦄进入系统\n * 2025-08-06 09:54:24 - 🐴无回复\n *"
)
#日志切换按钮
# 日志切换按钮
self.button = SwitchButton()
self.button.checkedChanged.connect(lambda checked: print("是否选中按钮:", checked))
# self.button.checkedChanged.connect(
# lambda checked: print("是否选中按钮:", checked)
# )
# 更改按钮状态
self.button.setChecked(True)
# 获取按钮是否选中
self.button.setOffText("报警")
self.button.setOnText("日志")
#状态按钮
#PillPushButton(self.tr('Tag'), self, FluentIcon.TAG),
# 状态按钮
# PillPushButton(self.tr('Tag'), self, FluentIcon.TAG),
self.state_button1 = PillPushButton()
self.state_button1.setFixedHeight(15)
self.state_button1.setFixedWidth(100)
self.state_button2 = PillPushButton("1",self,"")
self.state_button2 = PillPushButton("1", self, "")
self.state_button2.setFixedHeight(15)
self.state_button2.setFixedWidth(100)
self.state_button3 = PillPushButton("0",self,"")
self.state_button3 = PillPushButton("0", self, "")
self.state_button3.setFixedHeight(15)
self.state_button3.setFixedWidth(100)
@ -193,11 +230,11 @@ class TabInterface(QWidget):
self.state_button4.setFixedHeight(15)
self.state_button4.setFixedWidth(100)
self.state_button5 = PillPushButton("0",self,"")
self.state_button5 = PillPushButton("0", self, "")
self.state_button5.setFixedHeight(15)
self.state_button5.setFixedWidth(100)
self.state_button6 = PillPushButton("0",self,"")
self.state_button6 = PillPushButton("0", self, "")
self.state_button6.setFixedHeight(15)
self.state_button6.setFixedWidth(100)
@ -208,7 +245,7 @@ class TabInterface(QWidget):
self.state5 = DisplayLabel("当前工具号:")
self.state6 = DisplayLabel("报警代码:")
#状态hBoxLayout
# 状态hBoxLayout
self.state_container1 = QWidget()
self.state_hBoxLayout1 = QHBoxLayout(self.state_container1)
self.state_hBoxLayout1.addWidget(self.state1)
@ -239,13 +276,13 @@ class TabInterface(QWidget):
self.state_hBoxLayout6.addWidget(self.state6)
self.state_hBoxLayout6.addWidget(self.state_button6)
#日志vboxlayout
# 日志vboxlayout
self.container7 = QWidget()
self.vBoxLayout7 = QVBoxLayout(self.container7)
self.vBoxLayout7.addWidget(self.button)
self.vBoxLayout7.addWidget(self.textBrowser)
#状态vboxlayout
# 状态vboxlayout
self.container9 = QWidget()
self.vBoxLayout9 = QVBoxLayout(self.container9)
self.vBoxLayout9.addWidget(self.state_container1)
@ -255,13 +292,13 @@ class TabInterface(QWidget):
self.vBoxLayout9.addWidget(self.state_container5)
self.vBoxLayout9.addWidget(self.state_container6)
#日志+状态vboxlayout
# 日志+状态vboxlayout
self.container8 = QWidget()
self.hBoxLayout8 = QHBoxLayout(self.container8)
self.hBoxLayout8.addWidget(self.container7)
self.hBoxLayout8.addWidget(self.container9)
#self.songInterface = QLabel('Song Interface', self)
# self.songInterface = QLabel('Song Interface', self)
# self.albumInterface = QLabel('Album Interface', self)
# self.artistInterface = QLabel('Artist Interface', self)
@ -274,7 +311,7 @@ class TabInterface(QWidget):
# self.shadowEnabledCheckBox.setChecked(True)
# self.tabMaxWidthSpinBox.setRange(60, 400)
#self.tabMaxWidthSpinBox.setValue(self.tabBar.tabMaximumWidth())
# self.tabMaxWidthSpinBox.setValue(self.tabBar.tabMaximumWidth())
# self.closeDisplayModeComboBox.addItem(self.tr('Always'), userData=TabCloseButtonDisplayMode.ALWAYS)
# self.closeDisplayModeComboBox.addItem(self.tr('OnHover'), userData=TabCloseButtonDisplayMode.ON_HOVER)
@ -288,33 +325,33 @@ class TabInterface(QWidget):
# self.addSubInterface(self.artistInterface,
# 'tabArtistInterface', self.tr('Artist'), ':/gallery/images/Singer.png')
self.controlPanel.setObjectName('controlPanel')
self.controlPanel.setObjectName("controlPanel")
StyleSheet.SYSTEM_INTERFACE.apply(self)
#self.connectSignalToSlot()
# self.connectSignalToSlot()
# qrouter.setDefaultRouteKey(
# self.stackedWidget, self.songInterface.objectName())
# def connectSignalToSlot(self):
# self.movableCheckBox.stateChanged.connect(
# lambda: self.tabBar.setMovable(self.movableCheckBox.isChecked()))
# self.scrollableCheckBox.stateChanged.connect(
# lambda: self.tabBar.setScrollable(self.scrollableCheckBox.isChecked()))
# self.shadowEnabledCheckBox.stateChanged.connect(
# lambda: self.tabBar.setTabShadowEnabled(self.shadowEnabledCheckBox.isChecked()))
# self.movableCheckBox.stateChanged.connect(
# lambda: self.tabBar.setMovable(self.movableCheckBox.isChecked()))
# self.scrollableCheckBox.stateChanged.connect(
# lambda: self.tabBar.setScrollable(self.scrollableCheckBox.isChecked()))
# self.shadowEnabledCheckBox.stateChanged.connect(
# lambda: self.tabBar.setTabShadowEnabled(self.shadowEnabledCheckBox.isChecked()))
#self.tabMaxWidthSpinBox.valueChanged.connect(self.tabBar.setTabMaximumWidth)
# self.tabMaxWidthSpinBox.valueChanged.connect(self.tabBar.setTabMaximumWidth)
# self.tabBar.tabAddRequested.connect(self.addTab)
# self.tabBar.tabCloseRequested.connect(self.removeTab)
# self.tabBar.tabAddRequested.connect(self.addTab)
# self.tabBar.tabCloseRequested.connect(self.removeTab)
# self.stackedWidget.currentChanged.connect(self.onCurrentIndexChanged)
# self.stackedWidget.currentChanged.connect(self.onCurrentIndexChanged)
def initLayout(self):
# self.tabBar.setTabMaximumWidth(200)
#self.setFixedHeight(450)
# self.setFixedHeight(450)
self.setMaximumSize(787, 800)
self.setMinimumSize(450, 450)
self.controlPanel.setFixedWidth(220)
@ -322,7 +359,7 @@ class TabInterface(QWidget):
self.hBoxLayout.addWidget(self.controlPanel, 0, Qt.AlignRight)
self.hBoxLayout.setContentsMargins(0, 0, 0, 0)
#self.vBoxLayout.addWidget(self.tabBar)
# self.vBoxLayout.addWidget(self.tabBar)
# self.vBoxLayout.addWidget(self.stackedWidget)
self.vBoxLayout.setContentsMargins(0, 0, 0, 0)
@ -361,13 +398,13 @@ class TabInterface(QWidget):
# self.panelLayout.addWidget(self.closeDisplayModeLabel)
# self.panelLayout.addWidget(self.closeDisplayModeComboBox)
#左边窗口
# 左边窗口
# 创建加载框
#self.loading_button1=ToggleButton(self.tr('Start practicing'), self, FluentIcon.BASKETBALL)
self.loading_button1=ToggleButton()
self.loading_button2=ToggleButton()
self.loading_button3=ToggleButton()
self.loading_button4=ToggleButton()
# self.loading_button1=ToggleButton(self.tr('Start practicing'), self, FluentIcon.BASKETBALL)
self.loading_button1 = ToggleButton()
self.loading_button2 = ToggleButton()
self.loading_button3 = ToggleButton()
self.loading_button4 = ToggleButton()
self.loading1 = DisplayLabel("取料中...")
self.loading2 = DisplayLabel("拍照中...")
self.loading3 = DisplayLabel("抓料中...")
@ -390,7 +427,9 @@ class TabInterface(QWidget):
self.vBoxLayout.addWidget(self.video_label)
# 使用 OpenCV 读取视频
self.cap = cv2.VideoCapture("./app/resource/video/test.mp4") # 替换为你的视频路径
self.cap = cv2.VideoCapture(
"./app/resource/video/test.mp4"
) # 替换为你的视频路径
if not self.cap.isOpened():
print("无法打开视频文件!")
return
@ -399,11 +438,10 @@ class TabInterface(QWidget):
self.timer = QTimer()
self.timer.timeout.connect(self.update_frame)
self.timer.start(30) # 30ms 更新一帧(约 33 FPS
#self.vBoxLayout.addWidget()
# self.vBoxLayout.addWidget()
#左边窗口下面的日志栏位和状态栏
# 左边窗口下面的日志栏位和状态栏
self.vBoxLayout.addWidget(self.container8)
def addSubInterface(self, widget: QLabel, objectName, text, icon):
widget.setObjectName(objectName)
@ -421,12 +459,12 @@ class TabInterface(QWidget):
# self.tabBar.setCloseButtonDisplayMode(mode)
# def onCurrentIndexChanged(self, index):
# widget = self.stackedWidget.widget(index)
# if not widget:
# return
# widget = self.stackedWidget.widget(index)
# if not widget:
# return
# self.tabBar.setCurrentTab(widget.objectName())
# qrouter.push(self.stackedWidget, widget.objectName())
# self.tabBar.setCurrentTab(widget.objectName())
# qrouter.push(self.stackedWidget, widget.objectName())
def update_frame(self):
ret, frame = self.cap.read()
@ -441,4 +479,6 @@ class TabInterface(QWidget):
bytes_per_line = ch * w
q_img = QImage(frame.data, w, h, bytes_per_line, QImage.Format_RGB888)
pixmap = QPixmap.fromImage(q_img)
self.video_label.setPixmap(pixmap.scaled(self.video_label.size())) # 自适应窗口大小
self.video_label.setPixmap(
pixmap.scaled(self.video_label.size())
) # 自适应窗口大小