class CountLayout(QHBoxLayout): """Field with a QSpinBox""" def __init__(self, field, parent=None): QHBoxLayout.__init__(self) self.field = field self.count = QSpinBox() self.count.setFixedWidth(45) self.addWidget(self.field) self.addWidget(self.count) def text(self): return self.field.text() def currentIndex(self): return self.field.currentIndex() def n(self): return self.count.value() def setStyleSheet(self, style): self.field.setStyleSheet(style) self.count.setStyleSheet(style)
class StatisticsOptions(QWidget): polymorphic_states = { 'Regression': {'dtext': 'Tipo de Regressão:', 'xtext': 'Selecione a coluna dos valores correspondentes à variável independente:', 'ytext': 'Selecione a coluna dos valores correspondentes à variável dependente:', 'dropdown': ['Linear', 'Exponencial', 'Logarítmica', 'Potencial', 'Polinomial'], 'ctext':''}, 'Statistics': {'dtext': 'Tipo de análise estatística:', 'xtext': 'Selecione a coluna dos valores para realizar a análise:', 'ytext': '', 'dropdown': ['Média aritmética', 'Mediana', 'Moda', 'Variância Pop.', 'Variância Am.', 'Desvio Padrão Pop.', 'Desvio Padrão Am.', 'Máximo', 'Mínimo', 'Amplitude', 'Quartil', 'Percentil'], 'ctext':''}, 'Histogram': {'dtext': '', 'xtext': 'Selecione a coluna com os valores:', 'ytext': '', 'dropdown': [], 'ctext':''}, 'Boxplot': {'dtext': 'Orientação do gráfico:', 'ctext': 'Selecione as colunas onde se encontram as séries para o Boxplot (i.e. B, B:C, A:C:F:G):', 'ytext': '', 'dropdown': ['Vertical', 'Horizontal'], 'xtext':''}, } ready2calculate = Signal(bool) def __init__(self, _mode='Regression'): super().__init__() self.mode = _mode self.subtitle = QLabel(str(_mode)) self.dropdown_text = QLabel(self.polymorphic_states[self.mode]['dtext']) self.dropdown_text.setWordWrap(True) self.dropdown = Dropdown(self.polymorphic_states[self.mode]['dropdown']) self.x_column_text = QLabel(self.polymorphic_states[self.mode]['xtext']) self.x_column_text.setWordWrap(True) self.x_column = QLineEdit() self.y_column_text = QLabel(self.polymorphic_states[self.mode]['ytext']) self.y_column_text.setWordWrap(True) self.y_column = QLineEdit() self.column_range_text = QLabel(self.polymorphic_states[self.mode]['ctext']) self.column_range_text.setWordWrap(True) self.column_range = QLineEdit() self.output_text = QLabel('Select Output:') self.output_text.setWordWrap(True) self.table_button = QRadioButton('Tabela (Planilha)') self.plot_button = QRadioButton('Gráfico (Plot)') self.output_destination_text = QLabel('Selecione a coluna onde deve-se armazenar os resultados:') self.output_destination_text.setWordWrap(True) self.output_destination = QLineEdit() self.run_button = QPushButton('Começar Análise') self.selected_output = '' self.degree_l = QLabel('Ordem:') self.degree = QSpinBox() self.degree.setRange(1, 6) self.quartile_l = QLabel('Quartil:') self.quartile = QSpinBox() self.quartile.setRange(1, 4) self.percentile_l = QLabel('Percentil:') self.percentile = QSpinBox() self.percentile.setRange(1, 100) self.default_degree_stylesheet = self.degree.styleSheet() self.default_quartile_stylesheet = self.quartile.styleSheet() self.default_percentile_stylesheet = self.percentile.styleSheet() self.degree.setDisabled(True) self.results_l = QLabel('Resultados da análise: ') self.results = QTextEdit() self.payload = [] self.buildLayout() self.connections() self.initialState() self.setStyleSheet('color:white; font-family: Bahnschrift SemiLight Condensed; font-size: 14px;') self.x_column.setStyleSheet('background-color: white; color: black') self.y_column.setStyleSheet('background-color: white; color: black') self.column_range.setStyleSheet('background-color: white; color: black') self.results.setStyleSheet('background-color: white; color: black') def buildLayout(self): layout = QFormLayout() if len(self.dropdown_text.text()) > 0: layout.addWidget(self.dropdown_text) layout.addWidget(self.dropdown) if len(self.x_column_text.text()) > 0: layout.addWidget(self.x_column_text) layout.addWidget(self.x_column) if len(self.y_column_text.text()) > 0: layout.addWidget(self.y_column_text) layout.addWidget(self.y_column) if len(self.column_range_text.text()) > 0: layout.addWidget(self.column_range_text) layout.addWidget(self.column_range) if self.mode == 'Statistics': layout.addWidget(self.quartile_l) layout.addWidget(self.quartile) layout.addWidget(self.percentile_l) layout.addWidget(self.percentile) if self.mode == 'Regression': layout.addWidget(self.degree_l) layout.addWidget(self.degree) layout.addWidget(self.run_button) if self.mode != 'Boxplot' and self.mode != "Histogram": layout.addWidget(self.results_l) layout.addWidget(self.results) self.setLayout(layout) def initialState(self): self.output_destination.setDisabled(True) def connections(self): self.plot_button.clicked.connect(self.plotSelected) self.table_button.clicked.connect(self.tableSelected) self.run_button.clicked.connect(self.collectPayload) self.dropdown.currentTextChanged.connect(self.enableDegreeBox) def columnRangeDecomposition(self, text): try: return text.split(sep=':') except Exception: print('A problem happened in decomposing the column ranges. Probable bad user input.') def plotSelected(self): self.output_destination.setDisabled(True) self.selected_output = 'Plot' def enableDegreeBox(self, text): if text == 'Polinomial': self.degree.setStyleSheet('background-color: white; color: black') self.degree.setEnabled(True) else: self.degree.setStyleSheet(self.default_degree_stylesheet) self.degree.setDisabled(True) if text == 'Quartil': self.quartile.setStyleSheet('background-color: white; color: black') self.quartile.setEnabled(True) else: self.quartile.setStyleSheet(self.default_degree_stylesheet) self.quartile.setDisabled(True) if text == 'Percentil': self.percentile.setStyleSheet('background-color: white; color: black') self.percentile.setEnabled(True) else: self.percentile.setStyleSheet(self.default_degree_stylesheet) self.percentile.setDisabled(True) def tableSelected(self): self.output_destination.setDisabled(False) self.selected_output = 'Table' def collectPayload(self): if len(self.column_range_text.text()) > 0: a = self.columnRangeDecomposition(self.column_range.text()) b = 'V' else: a = None b = self.y_column.text() payload = { 'calculate': self.dropdown.currentText(), 'x_column': self.x_column.text(), 'y_column': b, 'z_column': None, 'column_range': a, 'output_selection': self.selected_output, 'output_column': self.output_destination.text() } self.payload = payload self.ready2calculate.emit(True)
class InputsLayout(QFormLayout): # this signal is connected to print_output from output_layout class. Connection is done in center_layout ga_result = Signal( str ) # a signal that is emitted so it can transfer resulting string to the output_layout class def __init__(self): super(InputsLayout, self).__init__() self.big_font = QFont() self.medium_font = QFont() self.header = QLabel() self.header_general = QLabel() self.header_fitness_remapping = QLabel() self.header_stop = QLabel() self.header_selection = QLabel() self.header_pairing = QLabel() self.header_crossover = QLabel() self.header_mutation = QLabel() self.inp_functions_combo = QComboBox() self.inp_num_variables = QSpinBox() self.inp_extrema_min = QRadioButton("Minimum") self.inp_extrema_max = QRadioButton("Maximum") self.inp_pop_size = QSpinBox() self.inp_lower_bound = QDoubleSpinBox() self.inp_upper_bound = QDoubleSpinBox() # Stopping self.inp_max_iter = QSpinBox() self.inp_similarity_cb = QCheckBox() self.inp_similarity = QSpinBox() self.inp_best_result_cb = QCheckBox() self.inp_best_result = QDoubleSpinBox() self.inp_average_result_cb = QCheckBox() self.inp_average_result = QDoubleSpinBox() # Fitness remapping self.inp_fitness_remapping = QComboBox() # Selection self.inp_selection_method = QComboBox() self.inp_elitism = QDoubleSpinBox() # Pairing self.inp_pairing_method = QComboBox() # Crossover self.inp_crossover_method = QComboBox() self.inp_crossover_fraction = QDoubleSpinBox() self.intermediate_offset = QDoubleSpinBox() # Mutation self.inp_mutation_method = QComboBox() self.inp_mutation_intensity = QDoubleSpinBox() self.inp_mutation_intensity_final = QDoubleSpinBox() self.init_fonts() self.init_header() self.init_row_functions() self.init_row_general() self.init_row_fitness_remapping() self.init_row_stop() self.init_row_selection() self.init_row_pairing() self.init_row_crossover() self.init_row_mutation() def init_fonts(self): self.big_font.setPointSizeF(14) self.medium_font.setPointSizeF(12) def init_header(self): self.header.setFont(self.big_font) self.header.setAlignment(Qt.AlignCenter) self.header.setText("Genetic Algorithm Continuous Optimization") self.addRow(self.header) self.addRow(QHLine()) def init_row_functions(self): self.inp_functions_combo.addItem("Ackley", ackley) self.inp_functions_combo.addItem("Griewank", griewank) self.inp_functions_combo.addItem("Michalewicz", michalewicz) self.inp_extrema_min.setChecked(True) radio_box = QHBoxLayout() radio_box.addWidget(self.inp_extrema_min) radio_box.addWidget(self.inp_extrema_max) self.addRow("Function:", self.inp_functions_combo) self.inp_num_variables.setMaximum(10000) self.inp_num_variables.setValue(10) self.addRow("Number of variables:", self.inp_num_variables) self.addRow("Find:", radio_box) self.addRow(QHLine()) def init_row_general(self): self.header_general.setFont(self.medium_font) self.header_general.setText("General") self.inp_pop_size.setMaximum(10000) self.inp_pop_size.setValue(300) self.inp_lower_bound.setMaximum(1000000) self.inp_lower_bound.setMinimum(-1000000.0) self.inp_lower_bound.setValue(-10) self.inp_upper_bound.setMaximum(1000000) self.inp_upper_bound.setMinimum(-1000000.0) self.inp_upper_bound.setValue(10) self.addRow(self.header_general) self.addRow("Population size", self.inp_pop_size) self.addRow("Lower Bound", self.inp_lower_bound) self.addRow("Upper Bound", self.inp_upper_bound) self.addRow(QHLine()) def init_row_fitness_remapping(self): self.header_fitness_remapping.setFont(self.medium_font) self.header_fitness_remapping.setText("Fitness Remapping") self.inp_fitness_remapping.addItem("Rank Scaling", "Rank Scaling") self.inp_fitness_remapping.addItem("Fitness Scaling", "Fitness Scaling") self.addRow(self.header_fitness_remapping) self.addRow("Fitness remapping", self.inp_fitness_remapping) self.addRow(QHLine()) def init_row_stop(self): self.header_stop.setFont(self.medium_font) self.header_stop.setText("Stopping Criteria") self.inp_max_iter.setMaximum(100000) self.inp_similarity.setMaximum(100000) self.inp_best_result.setMinimum(-100000) self.inp_best_result.setMaximum(100000) self.inp_average_result.setMinimum(-100000) self.inp_average_result.setMaximum(100000) self.inp_max_iter.setValue(500) self.inp_similarity.setValue(80) self.inp_best_result.setValue(-10) self.inp_average_result.setValue(-10000) self.inp_similarity_cb.setText("Similar Results") self.inp_best_result_cb.setText("Best Result") self.inp_average_result_cb.setText("Average Result") self.inp_similarity_cb.stateChanged.connect(self.cb_similarity_signal) self.inp_best_result_cb.stateChanged.connect( self.cb_best_result_signal) self.inp_average_result_cb.stateChanged.connect( self.cb_average_result_signal) self.inp_similarity_cb.setChecked(False) self.inp_best_result_cb.setChecked(False) self.inp_average_result_cb.setChecked(False) self.inp_similarity.setEnabled(True) self.inp_best_result.setEnabled(False) self.inp_best_result.setStyleSheet("background:#555") self.inp_average_result.setEnabled(False) self.inp_average_result.setStyleSheet("background:#555") self.addRow(self.header_stop) self.addRow("Max iter", self.inp_max_iter) self.addRow(self.inp_similarity_cb, self.inp_similarity) self.addRow(self.inp_best_result_cb, self.inp_best_result) self.addRow(self.inp_average_result_cb, self.inp_average_result) self.addRow(QHLine()) def init_row_selection(self): self.header_selection.setFont(self.medium_font) self.header_selection.setText("Selection") self.inp_selection_method.addItem("Fittest Half", "Fittest Half") self.inp_selection_method.addItem("Roulette Wheel", "Roulette Wheel") self.inp_selection_method.addItem("Random", "Random") self.inp_selection_method.addItem("Whole Population", "Whole Population") self.inp_elitism.setMaximum(1) self.inp_elitism.setValue(0.01) self.inp_elitism.setSingleStep(0.01) self.addRow(self.header_selection) self.addRow("Selection Method", self.inp_selection_method) self.addRow("Elitism Percentage", self.inp_elitism) self.addRow(QHLine()) def init_row_pairing(self): self.header_pairing.setFont(self.medium_font) self.header_pairing.setText("Pairing") self.inp_pairing_method.addItem("Random", "Random") self.inp_pairing_method.addItem("Roulette Wheel", "Roulette Wheel") self.inp_pairing_method.addItem("Fittest", "Fittest") self.addRow(self.header_pairing) self.addRow("Pairing Method", self.inp_pairing_method) self.addRow(QHLine()) def init_row_crossover(self): self.header_crossover.setFont(self.medium_font) self.header_crossover.setText("Crossover") self.inp_crossover_method.addItem("Intermediate", "Intermediate") self.inp_crossover_method.addItem("Line Intermediate", "Line Intermediate") self.inp_crossover_method.addItem("Heuristic", "Heuristic") self.inp_crossover_method.addItem("One point", "One point") self.inp_crossover_method.addItem("Two point", "Two point") self.inp_crossover_method.addItem("Random", "Random") self.inp_mutation_method.setCurrentIndex(2) self.inp_crossover_fraction.setMaximum(1) self.inp_crossover_fraction.setValue(0.7) self.inp_crossover_fraction.setSingleStep(0.05) self.intermediate_offset.setMaximum(20) self.intermediate_offset.setValue(1.55) self.intermediate_offset.setSingleStep(0.05) self.addRow(self.header_crossover) self.addRow("Crossover Method", self.inp_crossover_method) self.addRow("Crossover Fraction", self.inp_crossover_fraction) self.addRow("Intermediate Offset", self.intermediate_offset) self.addRow(QHLine()) def init_row_mutation(self): self.header_mutation.setFont(self.medium_font) self.header_mutation.setText("Mutation") self.inp_mutation_method.addItem("Gauss", "Gauss") self.inp_mutation_method.addItem("Random", "Random") self.inp_mutation_intensity.setMaximum(200) self.inp_mutation_intensity.setValue(2) self.inp_mutation_intensity.setDecimals(4) self.inp_mutation_intensity.setSingleStep(0.01) self.inp_mutation_intensity_final.setMaximum(200) self.inp_mutation_intensity_final.setDecimals(4) self.inp_mutation_intensity_final.setValue(0.001) self.inp_mutation_intensity_final.setSingleStep(0.5) self.addRow(self.header_mutation) self.addRow("Mutation Method", self.inp_mutation_method) self.addRow("Mutation Intensity", self.inp_mutation_intensity) self.addRow("Final Mutation Intensity", self.inp_mutation_intensity_final) self.addRow(QHLine()) def get_options(self): function = self.inp_functions_combo.currentData() num_var = self.inp_num_variables.text() if self.inp_extrema_min.isChecked(): extrem = 0 else: extrem = 1 pop_size = self.inp_pop_size.text() low_bound = self.inp_lower_bound.text() upp_bound = self.inp_upper_bound.text() max_iter = self.inp_max_iter.text() sim_results = self.inp_similarity.text() best_res = self.inp_best_result.text() average_res = self.inp_average_result.text() select_method = self.inp_selection_method.currentText() elite_percent = self.inp_elitism.text() pairing = self.inp_pairing_method.currentText() crossover_method = self.inp_crossover_method.currentText() crossover_fraction = self.inp_crossover_fraction.text() intermediate_offset = self.intermediate_offset.text() mutation_method = self.inp_mutation_method.currentText() mutation_intensity = self.inp_mutation_intensity.text() mutation_intensity_final = self.inp_mutation_intensity_final.text() fitness_remapping = self.inp_fitness_remapping.currentText() options = { "function": function, "num_var": num_var, "pop_size": int(pop_size), "max_iter": int(max_iter), "lower_bound": float(low_bound.replace(",", ".")), "upper_bound": float(upp_bound.replace(",", ".")), "find_max": extrem, "prints": 0, "average_result": float(average_res.replace(",", ".")), "best_result": float(best_res.replace(",", ".")), "similarity": float(sim_results.replace(",", ".")), "selection": select_method, "pairing": pairing, "crossover": crossover_method, "crossover_fraction": float(crossover_fraction.replace(",", ".")), "intermediate_offset": float(intermediate_offset.replace(",", ".")), # 0 mean child will be between parents, 1 mean offset is same as two parent distance "mutation": mutation_method, "mutation_intensity": float(mutation_intensity.replace(",", ".")), "mutation_intensity_final": float(mutation_intensity_final.replace(",", ".")), "elitism": float(elite_percent.replace(",", ".")), "fitness_remapping": fitness_remapping } if not self.inp_similarity_cb.isChecked(): options["similarity"] = None if not self.inp_best_result_cb.isChecked(): options["best_result"] = None if not self.inp_average_result_cb.isChecked(): options["average_result"] = None return options def cb_similarity_signal(self): if self.inp_similarity_cb.isChecked(): self.inp_similarity.setEnabled(True) self.inp_similarity.setStyleSheet("") else: self.inp_similarity.setEnabled(False) self.inp_similarity.setStyleSheet("background:#555") def cb_best_result_signal(self): if self.inp_best_result_cb.isChecked(): self.inp_best_result.setEnabled(True) self.inp_best_result.setStyleSheet("") else: self.inp_best_result.setEnabled(False) self.inp_best_result.setStyleSheet("background:#555") def cb_average_result_signal(self): if self.inp_average_result_cb.isChecked(): self.inp_average_result.setEnabled(True) self.inp_average_result.setStyleSheet("") else: self.inp_average_result.setEnabled(False) self.inp_average_result.setStyleSheet("background:#555")
class OscGui(QWidget): triggerEnable = 0 ADCEnable = 0 def __init__(self, device): QWidget.__init__(self) self.setWindowIcon(QIcon("icon/silabslogo.png")) self.device = device screen = QDesktopWidget() self.m_width = screen.width() self.m_height = screen.height() self.resize(self.m_width, self.m_height) self.showMaximized() self.setWindowTitle("Silabs") self.setObjectName("mainWindow") self.setStyleSheet("#mainWindow{background-color:rgb(54, 56, 60);}") self.layout = QtWidgets.QHBoxLayout() self.layout.setContentsMargins(self.m_width / 200, self.m_width / 200, self.m_width / 200, self.m_width / 20) self.layout.setSpacing(10) self.create_left_frame() self.create_right_frame() self.layout.setStretch(0, 3) self.layout.setStretch(1, 1) self.setLayout(self.layout) if self.device: logging.debug("device name:" + str(self.device)) self.readThread = USBReadThread(self.device) self.readThread.updateWaveForm.connect(self.update_canvas) self.readThread.updateFrequency.connect(self.update_frequency) self.readThread.singleTrigger.connect(self.single_trigger_event) self.readThread.start() self.frequencyGet = Protocol.PREAMBLE.value \ + Protocol.FREQUENCY_GET.value \ + '\x00' # '\xAA' + '\x41' + '\x00' self.setThread = USBWriteThread(self.device, self.frequencyGet) self.setThread.start() def create_left_frame(self): self.leftlayout = QtWidgets.QVBoxLayout() self.leftlayout.setContentsMargins(self.m_width / 200, self.m_width / 200, self.m_width / 200, self.m_width / 200) self.canvasFrame = CanvasFrame() # self.canvasFrame.setFrameStyle(QtWidgets.QFrame.StyledPanel | QtWidgets.QFrame.Plain) self.canvasFrame.setStyleSheet( "border-radius:10px;background-color:rgb(40, 38, 39);") self.leftlayout.addWidget(self.canvasFrame) self.navigationBarFrame = QtWidgets.QFrame() self.navigationBarFrame.setObjectName("NBF") self.navigationBarFrame.setStyleSheet( "#NBF{border-radius:10px;" "background-color:rgb(200, 200, 200);}") self.navigationBarLayout = QtWidgets.QVBoxLayout( self.navigationBarFrame) self.playBarLayout = QtWidgets.QHBoxLayout(self.navigationBarFrame) self.playBarLayout.setSpacing(self.m_width / 40) self.playBarLayout.addStretch(1) self.zoomInButton = QtWidgets.QPushButton() self.zoomInButton.setObjectName("zoomInButton") self.zoomInButton.setMaximumSize(self.m_width / 40, self.m_width / 40) self.zoomInButton.setMinimumSize(self.m_width / 40, self.m_width / 40) self.zoomInButton.setStyleSheet( "QPushButton{border-radius:25px;" "border-image:url(icon/ZoomIn.png);}" "QPushButton:hover{border-radius:25px;" "border-image:url(icon/ZoomIn2.png);" "background-colora:rgb(50, 50, 50,0);}") self.zoomInButton.clicked.connect(self.zoom_in_event) self.playBarLayout.addWidget(self.zoomInButton) self.zoomOutButton = QtWidgets.QPushButton() self.zoomOutButton.setObjectName("zoomOutButton") self.zoomOutButton.setMaximumSize(self.m_width / 40, self.m_width / 40) self.zoomOutButton.setMinimumSize(self.m_width / 40, self.m_width / 40) self.zoomOutButton.setIcon(QIcon("icon/ZoomOut.png")) self.zoomOutButton.setIconSize( QSize(self.m_width / 40, self.m_width / 40)) self.zoomOutButton.setStyleSheet( "QPushButton{border-radius:%dpx;}" "QPushButton:hover{border:1 solid red;" "border-radius:%dpx;" "background-color:rgb(250, 100, 100);}" % (self.m_width / 80, self.m_width / 80)) self.zoomOutButton.clicked.connect(self.zoom_out_event) self.playBarLayout.addWidget(self.zoomOutButton) self.playButton = QtWidgets.QPushButton() self.playButton.setObjectName("playButton") self.playButton.setFixedSize(self.m_width / 20, self.m_width / 20) # self.playButton.setStyleSheet("border-radius:%dpx;" % self.m_width/40) self.playButton.setStyleSheet("QPushButton{border:none;" "border-radius:%dpx;" "background-color:" "rgb(200, 100, 100);}" "QPushButton:hover{border:0;" "border-radius:%dpx;" "background-color:rgb(250, 100, 100);}" % (self.m_width / 40, self.m_width / 40)) self.playButton.clicked.connect(self.play_button_event) self.playBarLayout.addWidget(self.playButton) self.triggerLayout = QtWidgets.QHBoxLayout(self.navigationBarFrame) self.triggerLayout.setContentsMargins(0, 0, 0, 0) self.triggerLayout.setSpacing(1) self.triggerEnable = 0 self.triggerButton = QtWidgets.QPushButton(self.navigationBarFrame) # self.triggerButton.setObjectName("triggerButton") self.triggerButton.setFixedSize(self.m_width / 12, self.m_height / 20) self.triggerButton.setFont(QFont("New Time Roman", 10)) self.triggerButton.setText("Single Trigger") self.triggerButton.setStyleSheet( "QPushButton{border-top-left-radius:5px;" "border-bottom-left-radius: 5px;" "background-color:rgba(100, 100, 100,255);" "color:rgb(200, 200, 200);}" "QPushButton:hover{color: rgb(100, 200, 100);font-weight:bold}") self.triggerButton.clicked.connect(self.trigger_event) self.triggerLayout.addWidget(self.triggerButton) self.triggerValue = 0 self.triggerSpinBox = QSpinBox(self.navigationBarFrame) self.triggerSpinBox.setFixedSize(self.m_width / 10, self.m_height / 20) self.triggerSpinBox.setMaximum(3300) self.triggerSpinBox.setMinimum(1) self.triggerSpinBox.setFont(QFont("New Time Roman", 10)) self.triggerSpinBox.setStyleSheet( "QSpinBox{border-top-right-radius:5px;" "border-bottom-left-right: 5px;" "background-color:rgb(100, 100, 100);" "color:rgb(200, 200, 200);}" "QSpinBox:drop{subcontrol-origin: padding;" "subcontrol-position: top right;" "width: 50px;border-left-style:solid;" "border-top-right-radius: 3px;" "border-bottom-right-radius: 3px;" "border-left: 2px solid gray;" "background-color: rgba(100, 25, 100, 0);}") self.triggerSpinBox.setMinimumWidth(30) self.triggerLayout.addWidget(self.triggerSpinBox) self.playBarLayout.addLayout(self.triggerLayout) self.playBarLayout.addStretch(1) self.navigationBarLayout.addLayout(self.playBarLayout) self.navigationBarLine = QtWidgets.QFrame(self.navigationBarFrame) self.navigationBarLine.setAutoFillBackground(True) self.navigationBarLine.setFixedHeight(1) self.navigationBarLine.setStyleSheet( "background-color:rgb(150, 150, 150);") self.navigationBarLayout.addWidget(self.navigationBarLine) # self.navigationBarLayout.addStretch(1) self.leftlayout.addWidget(self.navigationBarFrame) self.leftlayout.setStretch(0, 5) self.leftlayout.setStretch(1, 1) self.leftlayout.setStretch(2, 1) self.leftlayout.setSpacing(self.m_width / 40) self.layout.addLayout(self.leftlayout) def create_right_frame(self): self.rightlayout = QtWidgets.QVBoxLayout() self.rightlayout.setContentsMargins(self.m_width / 200, self.m_width / 200, self.m_width / 200, self.m_width / 200) self.dialogFrame = QtWidgets.QFrame() self.dialogFrame.setObjectName("dialogFrame") # self.dialogFrame.setAutoFillBackground(True) # self.dialogFrame.setStyleSheet("#dialogFrame{border-radius:10px;" # "background-color:rgb(255, 100, 100);}") self.dialogFrame.setStyleSheet("#dialogFrame{border-radius:10px;" "background-color:rgb(10, 10, 10);}") self.dialoglayout = QtWidgets.QVBoxLayout(self.dialogFrame) self.dialoglayout.setContentsMargins(0, self.m_width / 40, 0, self.m_width / 40) # left, top, right, bottom self.dialoglayout.setSpacing(self.m_width / 40) self.dialoglayout.addStretch(2) self.ledLayout = QtWidgets.QHBoxLayout(self.dialogFrame) self.ledLayout.addStretch(1) self.redLedState = 0 self.redLedSwitch = QtWidgets.QPushButton(self.dialogFrame) self.redLedSwitch.setObjectName("redLedSwitch") self.redLedSwitch.setIcon(QIcon("icon/switchOFF.png")) self.redLedSwitch.setIconSize( QSize(self.m_width / 40, self.m_width / 40 / 1.75)) self.redLedSwitch.setFixedSize(self.m_width / 40, self.m_width / 40 / 1.75) self.redLedSwitch.setStyleSheet("#redLedSwitch{border:none;}") self.redLedSwitch.clicked.connect(self.red_led_switch_event) self.ledLayout.addWidget(self.redLedSwitch) self.ledLayout.addStretch(1) self.greenLedState = 0 self.greenLedSwitch = QtWidgets.QPushButton(self.dialogFrame) self.greenLedSwitch.setObjectName("greenLedSwitch") self.greenLedSwitch.setIcon(QIcon("icon/switchOFF.png")) self.greenLedSwitch.setIconSize( QSize(self.m_width / 40, self.m_width / 40 / 1.75)) self.greenLedSwitch.setFixedSize(self.m_width / 40, self.m_width / 40 / 1.75) self.greenLedSwitch.setStyleSheet("#greenLedSwitch{border:none;}") self.greenLedSwitch.clicked.connect(self.green_led_switch_event) self.ledLayout.addWidget(self.greenLedSwitch) self.ledLayout.addStretch(1) self.blueLedState = 0 self.blueLedSwitch = QtWidgets.QPushButton(self.dialogFrame) self.blueLedSwitch.setObjectName("blueLedSwitch") self.blueLedSwitch.setIcon(QIcon("icon/switchOFF.png")) self.blueLedSwitch.setIconSize( QSize(self.m_width / 40, self.m_width / 40 / 1.75)) self.blueLedSwitch.setFixedSize(self.m_width / 40, self.m_width / 40 / 1.75) self.blueLedSwitch.setStyleSheet("#blueLedSwitch{border:none;}") self.blueLedSwitch.clicked.connect(self.blue_led_switch_event) self.ledLayout.addWidget(self.blueLedSwitch) self.ledLayout.addStretch(1) self.dialoglayout.addLayout(self.ledLayout) self.dialoglayout.addStretch(1) self.dialogLine = QtWidgets.QFrame(self.dialogFrame) self.dialogLine.setAutoFillBackground(True) self.dialogLine.setFixedHeight(1) self.dialogLine.setStyleSheet("background-color:rgb(50, 50, 50);") self.dialoglayout.addWidget(self.dialogLine) self.channelLayout = QtWidgets.QHBoxLayout(self.dialogFrame) self.channelLayout.setSpacing(0) self.channelLayout.setContentsMargins(self.m_width / 100, 0, self.m_width / 100, 0) # self.channelLayout.addStretch(1) self.channel1Enable = 0 self.channel1Button = QPushButton(self.dialogFrame) self.channel1Button.setFixedHeight(self.m_width / 40) self.channel1Button.setStyleSheet( "QPushButton{border:1px solid rgb(200,200,200);" "border-top-left-radius:5px;" "border-bottom-left-radius: 5px;" "background-color:rgba(100, 100, 100,0);" "color:rgb(200, 200, 200);" "padding: 1px 20px;}" "QPushButton:hover{font-weight:bold;}") self.channel1Button.setFont(QFont("New Time Roman", 10)) self.channel1Button.setText("Channel_1") self.channel1Button.clicked.connect(self.channel1_button_event) self.channelLayout.addWidget(self.channel1Button) self.channel2Enable = 0 self.channel2Button = QPushButton(self.dialogFrame) self.channel2Button.setFixedHeight(self.m_width / 40) self.channel2Button.setStyleSheet( "QPushButton{border:1px solid rgb(200,200,200);" "border-top-right-radius: 5px;" "border-bottom-right-radius:5px;" "background-color:rgba(100, 100, 100,0);" "color:rgb(200, 200, 200);" "padding: 1px 20px;}" "QPushButton:hover{font-weight:bold;}") self.channel2Button.setFont(QFont("New Time Roman", 10)) self.channel2Button.setText("Channel_2") self.channel2Button.clicked.connect(self.channel2_button_event) self.channelLayout.addWidget(self.channel2Button) # self.channelLayout.addStretch(1) self.dialoglayout.addLayout(self.channelLayout) self.dialogLine2 = QtWidgets.QFrame(self.dialogFrame) self.dialogLine2.setAutoFillBackground(True) self.dialogLine2.setFixedHeight(1) self.dialogLine2.setStyleSheet("background-color:rgb(50, 50, 50);") self.dialoglayout.addWidget(self.dialogLine2) self.configutatorLayout = QtWidgets.QVBoxLayout(self.dialogFrame) self.configutatorLayout.setContentsMargins(20, 0, 20, 0) self.configutatorLayout.setSpacing(self.m_width / 100) self.frenquencyComboBox = QtWidgets.QComboBox() self.frenquencyComboBox.setObjectName("frenquencyComboBox") self.frenquencyComboBox.setFixedHeight(self.m_width / 40) self.frenquencyComboBox.setFont(QFont("New Time Roman", 10)) self.frenquencyComboBox.setStyleSheet( "QComboBox{border-radius:5px;" "background-color:rgb(200, 200, 200);" "color:rgb(0, 0, 0);" "padding: 1px 20px;}" "QComboBox:drop-down{subcontrol-origin: padding;" "subcontrol-position: top right;" "width: 50px;border-left-style:solid;" "border-top-right-radius: 3px;" "border-bottom-right-radius: 3px;" "border-left: 2px solid gray;" "background-color: rgba(100, 100, 100, 0);}" "QComboBox:down-arrow{border-image:url(icon/arrow-1.png);}") self.frenquencyComboBox.addItem("4Hz") self.frenquencyComboBox.addItem("10Hz") self.frenquencyComboBox.addItem("100Hz") self.frenquencyComboBox.addItem("1000Hz") self.frenquencyComboBox.setCurrentText("1000Hz") self.frenquencyComboBox.setFont(QFont("New Time Roman", 10)) self.configutatorLayout.addWidget(self.frenquencyComboBox) self.setButton = QPushButton(self.dialogFrame) self.setButton.setObjectName("setButton") self.setButton.setFixedHeight(self.m_width / 40) self.setButton.setStyleSheet( "QPushButton{border-radius:%dpx;" "background-color:rgb(150, 255, 150);" "color:rgb(0, 0, 0);" "text-align: center center;}" "QPushButton:hover{background-color:" "rgb(100, 255, 100);color:rgb(255, 100, 100);" "font-size:20px}" % (self.m_width / 80)) self.setButton.setFont(QFont("New Time Roman", 12, QFont.Bold)) self.setButton.setText("set") self.setButton.clicked.connect(self.set_button_event) self.setButton.setEnabled(True) self.configutatorLayout.addWidget(self.setButton) self.dialoglayout.addLayout(self.configutatorLayout) self.dialoglayout.addStretch(1) self.rightlayout.addWidget(self.dialogFrame) self.stateFrame = QtWidgets.QFrame() self.stateFrame.setObjectName("stateFrame") # self.dialogFrame.setAutoFillBackground(True) self.stateFrame.setStyleSheet( "QFrame{border:2px solid rgb(200, 200, 200);" "border-radius:10px;" "background-color:rgb(200, 200, 200);}") self.statelayout = QtWidgets.QGridLayout(self.stateFrame) self.statelayout.setContentsMargins(self.m_width / 40, self.m_width / 40, self.m_width / 40, self.m_width / 40) self.enableLabelKey = QLabel(self.stateFrame) self.enableLabelKey.setText("state:") self.enableLabelKey.setFont(QFont("New Time Roman", 10, QFont.Bold)) self.statelayout.addWidget(self.enableLabelKey, 0, 0) self.enableLabelValue = QLabel(self.stateFrame) self.enableLabelValue.setText("Stop") self.enableLabelValue.setFont(QFont("New Time Roman", 10, QFont.Bold)) self.statelayout.addWidget(self.enableLabelValue, 0, 1) self.frequencyLabelKey = QLabel(self.stateFrame) self.frequencyLabelKey.setText("frequency:") self.frequencyLabelKey.setFont(QFont("New Time Roman", 10, QFont.Bold)) self.statelayout.addWidget(self.frequencyLabelKey, 1, 0) self.frequencyLabelValue = QLabel(self.stateFrame) self.frequencyLabelValue.setText( str(self.canvasFrame.frequency) + "Hz") self.frequencyLabelValue.setFont( QFont("New Time Roman", 10, QFont.Bold)) self.statelayout.addWidget(self.frequencyLabelValue, 1, 1) self.bitModeLabelKey = QLabel(self.stateFrame) self.bitModeLabelKey.setText("BitMode:") self.bitModeLabelKey.setFont(QFont("New Time Roman", 10, QFont.Bold)) self.statelayout.addWidget(self.bitModeLabelKey, 2, 0) self.bitModeLabelValue = QLabel(self.stateFrame) self.bitModeLabelValue.setText("8 bit") self.bitModeLabelValue.setFont(QFont("New Time Roman", 10, QFont.Bold)) self.statelayout.addWidget(self.bitModeLabelValue, 2, 1) self.rightlayout.addWidget(self.stateFrame) self.rightlayout.addStretch(1) self.layout.addLayout(self.rightlayout) def trigger_event(self): if self.device is None: logging.error("no device!!!") return if self.triggerEnable: self.triggerButton.setStyleSheet( "QPushButton{border-top-left-radius:5px;" "border-bottom-left-radius: 5px;" "background-color:rgba(100, 100, 100,255);}" "QPushButton:hover{color: rgb(100, 200, 100);font-weight:bold}" ) self.triggerEnable = 0 self.triggerValue = 0 self.readThread.triggerEnable = 0 self.readThread.triggerValue = 0 self.triggerSpinBox.setEnabled(True) self.triggerSpinBox.setStyleSheet( "QSpinBox{border-top-right-radius:5px;" "border-bottom-left-right: 5px;" "background-color:rgb(100, 100, 100);" "color:rgb(200, 200, 200);}") else: self.triggerButton.setStyleSheet( "QPushButton{border:1px solid rgb(200,200,200);" "border-top-left-radius:5px;" "border-bottom-left-radius: 5px;" "background-color:rgba(100, 200, 100);}" "QPushButton:hover{color: rgb(100, 100, 100);font-weight:bold}" ) self.triggerEnable = 1 self.triggerValue = self.triggerSpinBox.value() self.readThread.triggerEnable = 1 self.readThread.triggerValue = self.triggerValue self.triggerSpinBox.setEnabled(False) self.triggerSpinBox.setStyleSheet( "QSpinBox{border-top-right-radius:5px;" "border-bottom-left-right: 5px;" "background-color:rgb(150, 150, 150);}") logging.debug("triggerButtonEvent:" + str(self.readThread.triggerEnable)) def zoom_in_event(self): if self.canvasFrame.scaleRatio == 1: self.canvasFrame.scaleRatio = 1 else: self.canvasFrame.scaleRatio = self.canvasFrame.scaleRatio - 1 self.canvasFrame.update() logging.debug("zoom_in_event, scaleRatio= " + str(self.canvasFrame.scaleRatio)) def zoom_out_event(self): if self.canvasFrame.scaleRatio > 5: self.canvasFrame.scaleRatio = 6 else: self.canvasFrame.scaleRatio = self.canvasFrame.scaleRatio + 1 self.canvasFrame.update() logging.debug("zoom_out_event, scaleRatio= " + str(self.canvasFrame.scaleRatio)) def play_button_event(self): logging.debug("playButtonEvent") if self.device is None: logging.error("no device!!!") return if self.ADCEnable: self.channel1Button.setEnabled(True) self.channel2Button.setEnabled(True) self.playButton.setStyleSheet( "QPushButton{border-radius:%dpx;" "background-color:rgb(200, 100, 100);}" "QPushButton:hover{border:0;" "border-radius:%dpx;" "background-color:rgb(250, 100, 100);}" % (self.m_width / 40, self.m_width / 40)) self.command = Protocol.PREAMBLE.value \ + Protocol.ENABLE_ADC.value \ + '\x01' \ + Protocol.DISABLE.value # '\xAA'+'\xF1'+'\x01'+'\x00' self.playthread = USBWriteThread(self.device, self.command) self.playthread.start() self.ADCEnable = 0 self.enableLabelValue.setText("Stop") self.setButton.setStyleSheet( "QPushButton{border-radius:%dpx;" "background-color:rgb(150, 255, 150);" "color:rgb(0, 0, 0);" "text-align: center center;}" "QPushButton:hover{background-color:rgb(100, 255, 100);" "color:rgb(255, 100, 100);" "font-size:20px;}" % (self.m_width / 80)) self.setButton.setEnabled(True) self.canvasFrame.dragEnable = True else: if self.channel1Enable == 0 and self.channel2Enable == 0: return if self.canvasFrame.frequency == 1000: self.freq = Protocol.FREQUENCY_1000HZ.value elif self.canvasFrame.frequency == 100: self.freq = Protocol.FREQUENCY_100HZ.value elif self.canvasFrame.frequency == 10: self.freq = Protocol.FREQUENCY_10HZ.value elif self.canvasFrame.frequency == 4: self.freq = Protocol.FREQUENCY_4HZ.value else: self.freq = Protocol.FREQUENCY_1000HZ.value self.frequencyCommand = Protocol.PREAMBLE.value \ + Protocol.FREQUENCY_SET.value \ + '\x01' \ + self.freq # '\xAA' + '\x43' + '\x01' + '\x03' self.frequencyThread = USBWriteThread(self.device, self.frequencyCommand) self.frequencyThread.start() self.channel1Button.setEnabled(False) self.channel2Button.setEnabled(False) self.playButton.setStyleSheet( "QPushButton{border-radius:%dpx;" "background-color:rgb(100, 200, 100);}" "QPushButton:hover{border:0;" "border-radius:%dpx;" "background-color:rgb(100, 250, 100);}" % (self.m_width / 40, self.m_width / 40)) self.command = Protocol.PREAMBLE.value \ + Protocol.ENABLE_ADC.value \ + '\x01' \ + Protocol.ENABLE.value # '\xAA'+'\xF1'+'\x01'+'\x01' self.playthread = USBWriteThread(self.device, self.command) self.playthread.start() self.ADCEnable = 1 self.enableLabelValue.setText("Runing") self.setButton.setStyleSheet("QPushButton{border-radius:%dpx;" "background-color:rgb(150, 150, 150);" "color:rgb(0, 0, 0);" "text-align: center center;}" % (self.m_width / 80)) self.setButton.setEnabled(False) self.canvasFrame.dragEnable = False self.canvasFrame.dragBias = 0 self.canvasFrame.dragBias_t = 0 def red_led_switch_event(self): if self.device is None: logging.error("no device!!!") return logging.debug("redled is pressed") if self.redLedState: self.redLedSwitch.setIcon(QIcon("icon/switchOFF.png")) self.redLedState = 0 self.ledCommand = Protocol.PREAMBLE.value \ + Protocol.LED_SET.value \ + '\x02' \ + Protocol.LED_RED.value \ + Protocol.LED_OFF.value # '\xAA' + '\x13' + '\x02' + '\x01' + '\x00' else: self.redLedSwitch.setIcon(QIcon("icon/switchRedOn.png")) self.redLedState = 1 self.ledCommand = Protocol.PREAMBLE.value \ + Protocol.LED_SET.value \ + '\x02' + Protocol.LED_RED.value \ + Protocol.LED_ON.value # '\xAA' + '\x13' + '\x02' + '\x01' + '\x01' self.ledThread = USBWriteThread(self.device, self.ledCommand) self.ledThread.start() def green_led_switch_event(self): if self.device is None: logging.error("no device!!!") return logging.debug("greenled is pressed") if self.greenLedState: self.greenLedSwitch.setIcon(QIcon("icon/switchOFF.png")) self.greenLedState = 0 self.ledCommand = Protocol.PREAMBLE.value \ + Protocol.LED_SET.value \ + '\x02' \ + Protocol.LED_GREEN.value \ + Protocol.LED_OFF.value # '\xAA' + '\x13' + '\x02' + '\x02' + '\x00' else: self.greenLedSwitch.setIcon(QIcon("icon/switchGreenOn.png")) self.greenLedState = 1 self.ledCommand = Protocol.PREAMBLE.value \ + Protocol.LED_SET.value \ + '\x02' \ + Protocol.LED_GREEN.value \ + Protocol.LED_ON.value # '\xAA' + '\x13' + '\x02' + '\x02' + '\x01' self.ledThread = USBWriteThread(self.device, self.ledCommand) self.ledThread.start() def blue_led_switch_event(self): if self.device is None: logging.error("no device!!!") return logging.debug("blueled is pressed") if self.blueLedState: self.blueLedSwitch.setIcon(QIcon("icon/switchOFF.png")) self.blueLedState = 0 self.ledCommand = Protocol.PREAMBLE.value \ + Protocol.LED_SET.value \ + '\x02' \ + Protocol.LED_BLUE.value \ + Protocol.LED_OFF.value # '\xAA' + '\x13' + '\x02' + '\x03' + '\x00' else: self.blueLedSwitch.setIcon(QIcon("icon/switchBlueOn.png")) self.blueLedState = 1 self.ledCommand = Protocol.PREAMBLE.value \ + Protocol.LED_SET.value \ + '\x02' \ + Protocol.LED_BLUE.value \ + Protocol.LED_ON.value # '\xAA' + '\x13' + '\x02' + '\x03' + '\x01' self.ledThread = USBWriteThread(self.device, self.ledCommand) self.ledThread.start() def channel1_button_event(self): if self.device is None: logging.error("no device!!!") return if self.channel1Enable: del self.canvasFrame.Channel1List[:] self.command = Protocol.PREAMBLE.value \ + Protocol.ENABLE_CHANNEL.value \ + '\x02' \ + Protocol.CHANNEL1.value \ + Protocol.DISABLE.value # '\xAA'+'\xF1'+'\x01'+'\x00' self.channel1thread = USBWriteThread(self.device, self.command) self.channel1thread.start() self.channel1Enable = 0 self.canvasFrame.channel1Enable = 0 self.channel1Button.setStyleSheet( "QPushButton{border:1px solid rgb(200,200,200);" "border-top-left-radius:5px;" "border-bottom-left-radius: 5px;" "background-color:rgba(100, 100, 100,0);" "color:rgb(200, 200, 200);" "padding: 1px 20px;}" "QPushButton:hover{font-weight:bold;}") logging.debug("channel1 disable") else: self.command = Protocol.PREAMBLE.value \ + Protocol.ENABLE_CHANNEL.value \ + '\x02' \ + Protocol.CHANNEL1.value \ + Protocol.ENABLE.value # '\xAA'+'\xF1'+'\x01'+'\x00' self.channel1thread = USBWriteThread(self.device, self.command) self.channel1thread.start() self.channel1Enable = 1 self.canvasFrame.channel1Enable = 1 self.channel1Button.setStyleSheet( "QPushButton{border:1px solid rgb(200,200,200);" "border-top-left-radius:5px;" "border-bottom-left-radius: 5px;" "background-color:rgba(200, 100, 100,255);" "color:rgb(200, 200, 200);" "padding: 1px 20px;}" "QPushButton:hover{font-weight:bold;}") logging.debug("channel1 enable") def channel2_button_event(self): if self.device is None: logging.error("no device!!!") return if self.channel2Enable: del self.canvasFrame.Channel2List[:] self.command2 = Protocol.PREAMBLE.value \ + Protocol.ENABLE_CHANNEL.value \ + '\x02' \ + Protocol.CHANNEL2.value \ + Protocol.DISABLE.value # '\xAA'+'\xF1'+'\x01'+'\x00' self.channel2thread = USBWriteThread(self.device, self.command2) self.channel2thread.start() self.channel2Enable = 0 self.canvasFrame.channel2Enable = 0 self.channel2Button.setStyleSheet( "QPushButton{border:1px solid rgb(200,200,200);" "border-top-right-radius:5px;" "border-bottom-right-radius: 5px;" "background-color:rgba(100, 100, 100,0);" "color:rgb(200, 200, 200);" "padding: 1px 20px;}" "QPushButton:hover{font-weight:bold;}") logging.debug("channel2 disable") else: self.command2 = Protocol.PREAMBLE.value \ + Protocol.ENABLE_CHANNEL.value \ + '\x02' \ + Protocol.CHANNEL2.value \ + Protocol.ENABLE.value # '\xAA'+'\xF1'+'\x01'+'\x00' self.channel2thread = USBWriteThread(self.device, self.command2) self.channel2thread.start() self.channel2Enable = 1 self.canvasFrame.channel2Enable = 1 self.channel2Button.setStyleSheet( "QPushButton{border:1px solid rgb(200,200,200);" "border-top-right-radius:5px;" "border-bottom-right-radius: 5px;" "background-color:rgba(0, 200, 255,255);" "color:rgb(200, 200, 200);" "padding: 1px 20px;}" "QPushButton:hover{font-weight:bold;}") logging.debug("channel2 enable") def set_button_event(self): if self.device is None: logging.error("no device!!!") return logging.debug("setButton is pressed" + str(self.frenquencyComboBox.currentIndex()) + '+' + self.frenquencyComboBox.currentText()) if self.frenquencyComboBox.currentText() == '1000Hz': self.canvasFrame.frequency = 1000 self.readThread.frequency = 1000 elif self.frenquencyComboBox.currentText() == '100Hz': self.canvasFrame.frequency = 100 self.readThread.frequency = 100 elif self.frenquencyComboBox.currentText() == '10Hz': self.canvasFrame.frequency = 10 self.readThread.frequency = 10 elif self.frenquencyComboBox.currentText() == '4Hz': self.canvasFrame.frequency = 4 self.readThread.frequency = 4 else: logging.warning("error frequency value:" + self.frenquencyComboBox.currentText()) self.frequencyLabelValue.setText(self.frenquencyComboBox.currentText()) def update_canvas(self, state): logging.debug("update_canvas:" + state) self.canvasFrame.update() def update_frequency(self, frequency): logging.debug("update_frequency") if self.readThread: self.frequencyLabelValue.setText(str(frequency) + "(HZ)") if frequency == 0: logging.warning("receive wrong frequency:0") else: self.canvasFrame.frequency = frequency def single_trigger_event(self, state): logging.debug("single_trigger_event:" + state) if self.ADCEnable == 0: return self.command = Protocol.PREAMBLE.value \ + Protocol.ENABLE_ADC.value \ + '\x01' \ + Protocol.DISABLE.value # '\xAA' + '\xF2' + '\x01' + '\x00' self.playThread = USBWriteThread(self.device, self.command) self.playThread.start() self.ADCEnable = 0 self.enableLabelValue.setText("Stop") self.playButton.setStyleSheet("QPushButton{border:none;" "border-radius:%dpx;" "background-color:rgb(200, 100, 100);}" "QPushButton:hover{border:0;" "border-radius:%dpx;" "background-color:rgb(250, 100, 100);}" % (self.m_width / 40, self.m_width / 40)) self.setButton.setStyleSheet( "QPushButton{border-radius:%dpx;" "background-color:rgb(150, 255, 150);" "color:rgb(0, 0, 0);" "text-align: center center;}" "QPushButton:hover{background-color:rgb(100, 255, 100);" "color:rgb(255, 100, 100);" "font-size:20px}" % (self.m_width / 80)) self.setButton.setEnabled(True) self.channel1Button.setEnabled(True) self.channel2Button.setEnabled(True) logging.debug("trigger!!! sample stop") def closeEvent(self, *args, **kwargs): logging.debug("this closeEvent -------------") if self.device: self.device.close() self.readThread.terminate() self.readThread.wait() def __del__(self): logging.debug("this del -------------")