def gui(self, **kwargs): from hyperclass.learn.manager import learningManager self.show_unlabeled = kwargs.get('show_unlabeled', True) with_learning = kwargs.get('learning', False) self.console = QWidget() console_layout = QVBoxLayout() self.console.setLayout(console_layout) radio_button_style = [ "border-style: outset", "border-width: 4px", "padding: 6px", "border-radius: 10px" ] labels_frame = QFrame(self.console) buttons_frame_layout = QVBoxLayout() labels_frame.setLayout(buttons_frame_layout) labels_frame.setFrameStyle(QFrame.StyledPanel | QFrame.Raised) labels_frame.setLineWidth(3) console_layout.addWidget(labels_frame) title = QLabel("Classes") title.setStyleSheet("font-weight: bold; color: black; font: 16pt") buttons_frame_layout.addWidget(title) for index, label in enumerate(self._labels): if (index > 0) or self.show_unlabeled: radiobutton = QRadioButton(label, self.console) radiobutton.index = index raw_color = [str(int(c * 155.99)) for c in self._colors[index]] qcolor = [ str(150 + int(c * 105.99)) for c in self._colors[index] ] style_sheet = ";".join(radio_button_style + [ f"background-color:rgb({','.join(qcolor)})", f"border-color: rgb({','.join(raw_color)})" ]) radiobutton.setStyleSheet(style_sheet) radiobutton.toggled.connect(self.onClicked) buttons_frame_layout.addWidget(radiobutton) self.buttons.append(radiobutton) buttons_frame = QFrame(self.console) buttons_frame_layout = QVBoxLayout() buttons_frame.setLayout(buttons_frame_layout) buttons_frame.setFrameStyle(QFrame.StyledPanel | QFrame.Raised) buttons_frame.setLineWidth(3) console_layout.addWidget(buttons_frame) title = QLabel("Actions") title.setStyleSheet("font-weight: bold; color: black; font: 16pt") buttons_frame_layout.addWidget(title) actions = ['Mark', 'Spread', 'Distance', 'Embed'] if with_learning: actions = actions + ['Learn', 'Apply'] learningManager.activate() actions = actions + ['Undo', 'Clear'] for action in actions: pybutton = QPushButton(action, self.console) pybutton.clicked.connect(partial(self.execute, action)) buttons_frame_layout.addWidget(pybutton) console_layout.addStretch(1) self.buttons[0].setChecked(True) self.activate_event_listening() return self.console
def __init__(self, parent): super(QWidget, self).__init__(parent) self.layout = QVBoxLayout(self) self.i2cspeed = 0 # Initialize tab screen self.tabs = QTabWidget() self.tab1 = QWidget() self.tab2 = QWidget() self.tabs.resize(300, 200) # Add tabs self.tabs.addTab(self.tab1, "I2C") self.tabs.addTab(self.tab2, "SPI") self.tab1.layout = QVBoxLayout(self) groupbox = QGroupBox("Connect") groupbox.setFixedSize(650, 100) groupbox.setCheckable(False) self.tab1.layout.addWidget(groupbox) hbox = QHBoxLayout() groupbox.setLayout(hbox) ''' 1. ~5KHz 2. ~50KHz 3. ~100KHz 4. ~400KHz ''' # Add tabs to widget radiobutton = QRadioButton("~5KHz") radiobutton.speed = "~5KHz" radiobutton.index = 1 radiobutton.toggled.connect(self.onClickedRadio) hbox.addWidget(radiobutton) radiobutton = QRadioButton("~50KHz") radiobutton.speed = "~50KHz" radiobutton.index = 2 radiobutton.toggled.connect(self.onClickedRadio) hbox.addWidget(radiobutton) radiobutton = QRadioButton("~100KHz") radiobutton.speed = "~100KHz" radiobutton.index = 3 radiobutton.toggled.connect(self.onClickedRadio) hbox.addWidget(radiobutton) radiobutton = QRadioButton("~400KHz") radiobutton.speed = "~400KHz" radiobutton.index = 4 radiobutton.toggled.connect(self.onClickedRadio) hbox.addWidget(radiobutton) hbox.addStretch() self.pushButton1 = QPushButton("Connect BP to I2C") self.pushButton1.clicked.connect(self.onClickedButton) hbox.addWidget(self.pushButton1) self.tab1.setLayout(self.tab1.layout) self.connectionstatusLabel = QLabel("Not Connected") hbox.addWidget(self.connectionstatusLabel) self.layout.addWidget(self.tabs) self.setLayout(self.layout) """ " Power Options Box """ groupboxpo = QGroupBox("Power Options") groupboxpo.setFixedSize(650, 100) groupboxpo.setCheckable(False) hboxpo = QHBoxLayout() groupboxpo.setLayout(hboxpo) checkbox = QCheckBox("Power") checkbox.option = "Power" checkbox.state = -1 checkbox.code = "w" checkbox.setChecked(False) checkbox.clicked.connect(self.toggle) hboxpo.addWidget(checkbox) checkbox = QCheckBox("PU Resistor") checkbox.option = "PU Resistor" checkbox.state = -1 checkbox.code = "p" checkbox.setChecked(False) checkbox.clicked.connect(self.toggle) hboxpo.addWidget(checkbox) checkbox = QCheckBox("Aux") checkbox.option = "Aux" checkbox.state = -1 checkbox.code = "a" checkbox.setChecked(False) checkbox.clicked.connect(self.toggle) hboxpo.addWidget(checkbox) hboxpo.addStretch() self.tab1.layout.addWidget(groupboxpo) """ " Read Write Box """ groupboxrw = QGroupBox("Read/Write") groupboxrw.setFixedSize(650, 100) groupboxrw.setCheckable(False) hboxrw = QHBoxLayout() groupboxrw.setLayout(hboxrw) lbl = QLabel("Data Size") self.labelIn = QLineEdit() self.labelIn.setFixedSize(60, 20) labelBtn = QPushButton("Submit") labelBtn.clicked.connect(self.onClickedSize) hboxrw.addWidget(lbl) hboxrw.addWidget(self.labelIn) hboxrw.addWidget(labelBtn) cmdLbl = QLabel("Cmd:") hboxpo.addStretch() self.cmd = QLineEdit() self.cmd.setFixedSize(250, 20) hboxrw.addWidget(cmdLbl) hboxrw.addWidget(self.cmd) self.pushButton2 = QPushButton("Send") self.pushButton2.clicked.connect(self.onClickedCmd) hboxrw.addWidget(self.pushButton2) self.tab1.layout.addWidget(groupboxrw) self.dataBox = QTableWidget() self.dataBox.setRowCount(8) self.dataBox.setColumnCount(8) self.tab1.layout.addWidget(self.dataBox)