from component.widget_channel.ui_widget_channel import Ui_Widget_Channel from PySide6.QtWidgets import (QWidget, QDialog, QVBoxLayout, QComboBox, QPushButton, QLabel, QTableWidgetItem, QAbstractScrollArea, QHBoxLayout, QStyledItemDelegate, QCheckBox) from PySide6.QtCore import Qt, Signal, QEvent from PySide6.QtGui import QPainter, QColor, QPen, QBrush, QPainterPath class Widget_Channel(Ui_Widget_Channel, QWidget): channel_btn_clicked = Signal(int) # (channel_index) solo_btn_clicked = Signal(int) # (channel_index) checkbox_clicked = Signal(int) # (channel_index) def __init__(self): super().__init__() self.ui = Ui_Widget_Channel() self.ui.setupUi(self) # Set white background color self.setStyleSheet("QWidget#Widget_Channel { background-color: white; }") self.setup_connections() def setup_connections(self): # Connect channel buttons using a loop for i in range(24): # Connect Channel buttons channel_btn = getattr(self.ui, f'pushButton_Channel_CH{i+1}') channel_btn.clicked.connect(lambda checked, index=i: self.channel_btn_clicked.emit(index)) # Connect SOLO buttons solo_btn = getattr(self.ui, f'pushButton_SOLO_CH{i+1}') solo_btn.clicked.connect(lambda checked, index=i: self.solo_btn_clicked.emit(index)) # Connect Mute checkboxes checkbox = getattr(self.ui, f'checkBox_CH{i+1}') checkbox.clicked.connect(lambda checked, index=i: self.checkbox_clicked.emit(index)) if __name__ == '__main__': import sys from PySide6.QtWidgets import QApplication app = QApplication(sys.argv) # Create and show the widget widget = Widget_Channel() widget.setup_connections() widget.show() widget.channel_btn_clicked.connect(lambda index: print(f"Channel button {index} clicked")) widget.solo_btn_clicked.connect(lambda index: print(f"Solo button {index} clicked")) widget.checkbox_clicked.connect(lambda index: print(f"Checkbox {index} clicked")) # Start the event loop sys.exit(app.exec())