update 更新IO面板

This commit is contained in:
FrankCV2048
2024-10-30 23:19:05 +08:00
parent 24e7bea71a
commit da0863308c
9 changed files with 1307 additions and 9 deletions

View File

@ -1,4 +1,4 @@
from PySide6.QtWidgets import QApplication, QWidget, QLabel, QPushButton
from PySide6.QtWidgets import QApplication, QWidget, QLabel
from PySide6.QtCore import QPropertyAnimation, QRect, QSize
@ -47,5 +47,32 @@ class ToggleSwitch(QWidget):
self.animation.start()
class MainWindow(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("Toggle Switch Example")
self.setFixedSize(200, 100)
# 创建滑动开关按钮
self.toggle = ToggleSwitch(self)
self.toggle.move(70, 35) # 将开关放置在窗口中间
# 创建状态标签
self.label = QLabel("Switch is OFF", self)
self.label.move(70, 70)
# 连接滑动开关的状态切换
self.toggle.animation.finished.connect(self.update_label)
def update_label(self):
# 更新标签显示的开关状态
if self.toggle.is_on:
self.label.setText("Switch is ON")
else:
self.label.setText("Switch is OFF")
app = QApplication([])
window = MainWindow()
window.show()
app.exec()