def __create_spinbox_label(self, value: int, label: str, minimum: int, maximum: int, min_width: int = 200) -> Tuple[Dict, Dict]: """__create_line_label will create a spinner and corresponding label Arguments: value {int} -- Default value label {str} -- Label name minimum {int} -- Minimum value maximum {int} -- Maximum value min_width {int} -- Minium width (default: {200}) Returns: Tuple[Dict, Dict] -- Line Edit, Label """ spin_box = QSpinBox() spin_box.setValue(value) spin_box.setMinimumWidth(min_width) spin_box.setMinimum(minimum) spin_box.setMaximum(maximum) label = QLabel(label) label.setBuddy(spin_box) return spin_box, label
def __init__(self, comms, parent): super().__init__(parent) toolbar = QHBoxLayout() clearButton = QPushButton("Clear") clearButton.clicked.connect(self.clear.emit) level = QComboBox() level.addItems(LEVELS) level.currentIndexChanged.connect(self.changeLevel.emit) maxBlock = QSpinBox() maxBlock.setMaximum(1000000) maxBlock.setSingleStep(10) maxBlock.valueChanged.connect(self.setSize.emit) maxBlock.setValue(1000) maxBlock.setMinimumWidth(100) toolbar.addWidget(clearButton) toolbar.addWidget(QLabel("Level")) toolbar.addWidget(level) toolbar.addWidget(QLabel("Current")) def addLevelLabel(comm): currentLevel = QLabel("---") toolbar.addWidget(currentLevel) comm.logLevel.connect(lambda data: currentLevel.setText(LEVELS[ _levelToIndex(data.level)])) if _isCommArray(comms): for comm in comms: addLevelLabel(comm) else: addLevelLabel(comms) toolbar.addWidget(QLabel("Max lines")) toolbar.addWidget(maxBlock) toolbar.addStretch() if issubclass(type(parent), QDockWidget): floatButton = QPushButton( self.style().standardIcon(QStyle.SP_TitleBarNormalButton), "") def _toggleFloating(): parent.setFloating(not parent.isFloating()) floatButton.clicked.connect(_toggleFloating) closeButton = QPushButton( self.style().standardIcon(QStyle.SP_TitleBarCloseButton), "") closeButton.clicked.connect(parent.close) toolbar.addWidget(floatButton) toolbar.addWidget(closeButton) self.setLayout(toolbar)
class IntEditor(QWidget): def __init__(self, minval, maxval, stepsize=1, parent=None): super(IntEditor, self).__init__(parent) # Editfield self.edit = QSpinBox(self) self.edit.setKeyboardTracking(False) self.edit.setRange(minval, maxval) self.edit.setSingleStep(stepsize) self.edit.setMinimumWidth(70) # Slider self.slider = QSlider(orientation=Qt.Vertical, parent=self) self.slider.setRange(minval, maxval) self.slider.setSingleStep(stepsize) self.slider.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding) # Ticks q_ticks = QSlider.TicksBelow self.slider.setTickPosition(q_ticks) tick_amount = 6 tick_interval = int(np.floor((maxval - minval) / tick_amount)) self.slider.setTickInterval(tick_interval) # ...labels font = QFont() font.setPointSize(8) tick_str1 = QLabel('{:d}'.format(minval), self) tick_str2 = QLabel('{:d}'.format(maxval), self) tick_str1.setFont(font) tick_str2.setFont(font) slider_tick_layout = QGridLayout() tick_str1.setAlignment(Qt.AlignBottom | Qt.AlignLeft) tick_str2.setAlignment(Qt.AlignTop | Qt.AlignLeft) slider_tick_layout.addWidget(self.slider, 0, 0, tick_amount, 1) slider_tick_layout.addWidget(tick_str2, 0, 1, 1, 1) slider_tick_layout.addWidget(tick_str1, tick_amount - 1, 1, 1, 1) # Layout layout = QVBoxLayout() layout.addLayout(slider_tick_layout) layout.addWidget(self.edit) self.setLayout(layout) # Signals and slots self.edit.valueChanged.connect(self.slider.setValue) self.slider.valueChanged.connect(self.edit.setValue)
class EditSlider(QWidget): def __init__(self, parent=None): super().__init__(parent) hlayout = QHBoxLayout() hlayout.setContentsMargins(0, 0, 0, 0) hlayout.setSpacing(2) self.edit = QSpinBox() self.edit.setMinimumWidth(40) self.edit.setButtonSymbols(QAbstractSpinBox.NoButtons) self.slider = QSlider(Qt.Horizontal) hlayout.addWidget(self.edit) hlayout.addWidget(self.slider) self.setLayout(hlayout) self.slider.valueChanged.connect(self.setValue) self.edit.valueChanged.connect(self.setValue) def setRange(self, min_val, max_val): self.edit.setRange(min_val, max_val) self.slider.setRange(min_val, max_val) def value(self) -> int: return self.edit.value() def setValue(self, value: int): if self.sender() != self.slider and self.sender() != self.edit: self.edit.setValue(value) self.slider.setValue(value) return if self.sender() == self.slider: self.edit.setValue(value) if self.sender() == self.edit: self.slider.setValue(value)
class RenameOptionsView(QWidget): """View responsible for holding renaming options. Attributes: layout (QVBoxLayout): Main layout of view. frame_layout (QVBoxLayout: Layout of frame which holds options. frame (QFrame): Frame surrounding options. prefix_h_layout (QHBoxLayout): Layout holding prefix options. complete_rename_h_layout (QHBoxLayout): Layout holding complete rename options. search_and_replace_h_layout (QHBoxLayout): Layout holding search and replace options. renumber_h_layout (QHBoxLayout): Layout holding renumber options. remove_ext_h_layout (QHBoxLayout): Layout holding remove options. change_ext_h_layout (QHBoxLayout): Layout holding change extension options. create_backup_h_layout (QHBoxLayout): Layout holding backup options. preview_h_layout (QHBoxLayout): Layout holding preview options. start_lbl (QLabel): Label for renumbering start. padding_lbl (QLabel): Label for renumbering padding. add_prefix_cb (QCheckBox): Used to signify the user wants to add a prefix to the renaming. prefix (QLineEdit): prefix to add. complete_rename_cb (QCheckBox): Used to signify the user wants to completely rename the file. new_name (QLineEdit): New name used when renaming. search_and_replace_cb (QCheckBox): Used to signify the user wants to partially rename files. find (QLineEdit): When searching and replacing this is what the user wants to search for. replace (QLineEdit): When searching and replacing this is what the user wants to replace with. renumber_cb (QCheckBox): Used to signify the user wants to renumber while renaming. start_num (QSpinBox): Number to start with when renumbering files. padding (QComboBox): Padding to apply to renaming when renumbering files. dot_cb (QCheckBox): When checked a dot will be used to separate the renumber from the name. remove_ext_cb (QCheckBox): Used to signify the user wants to remove extensions when renaming. backup_files_cb (QCheckBox): Used to signify the user wants to backup old files before renaming. change_ext_cb (QCheckBox): Used to signify the user wants to change the extension while renaming. change_ext (QLineEdit): New extension to add to the renamed file. preview_cb (QCheckBox): Used to signify the user wants to preview the rename before renaming. """ def __init__(self): super(RenameOptionsView, self).__init__() self.layout = QVBoxLayout() self.frame_layout = QVBoxLayout() self.options_lbl = QLabel(prefs.OPTIONS) self.frame = QFrame() self.prefix_h_layout = QHBoxLayout() self.complete_rename_h_layout = QHBoxLayout() self.search_and_replace_h_layout = QHBoxLayout() self.renumber_h_layout = QHBoxLayout() self.remove_ext_h_layout = QHBoxLayout() self.change_ext_h_layout = QHBoxLayout() self.create_backup_h_layout = QHBoxLayout() self.preview_h_layout = QHBoxLayout() self.start_lbl = QLabel(prefs.START_NUM) self.padding_lbl = QLabel(prefs.PADDING) self.add_prefix_cb = QCheckBox(prefs.PREFIX) self.prefix = QLineEdit(prefs.PREFIX_DEFAULT) self.complete_rename_cb = QCheckBox(prefs.COMPLETE_RENAME) self.new_name = QLineEdit(prefs.COMPLETE_RENAME_DEFAULT) self.search_and_replace_cb = QCheckBox(prefs.SEARCH_AND_REPLACE) self.find = QLineEdit(prefs.SEARCH_AND_REPLACE_DEFAULT) self.replace = QLineEdit(prefs.REPLACE_WITH_DEFAULT) self.renumber_cb = QCheckBox(prefs.RENUMBER) self.start_num = QSpinBox() self.padding = QComboBox() self.dot_cb = QCheckBox(prefs.USE_DOT) self.remove_ext_cb = QCheckBox(prefs.REMOVE_EXT) self.backup_files_cb = QCheckBox(prefs.BACKUP) self.change_ext_cb = QCheckBox(prefs.CHANGE_EXT) self.change_ext = QLineEdit(prefs.CHANGE_EXT_DEFAULT) self.preview_cb = QCheckBox(prefs.PREVIEW) self._configure() def _configure(self) -> None: """Configure the RenameOptionsView.""" self.frame.setLayout(self.frame_layout) self.frame.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken) self.layout.addWidget(self.options_lbl) self.layout.addWidget(self.frame) self.add_prefix_cb.setToolTip(prefs.PREFIX_TOOLTIP) self.prefix.setDisabled(True) self.prefix.setMaximumWidth(prefs.PREFIX_WIDTH) self.prefix.setMinimumWidth(prefs.PREFIX_WIDTH) self.complete_rename_cb.setToolTip(prefs.COMPLETE_RENAME_TOOLTIP) self.new_name.setDisabled(True) self.new_name.setMaximumWidth(prefs.NEW_NAME_WIDTH) self.new_name.setMinimumWidth(prefs.NEW_NAME_WIDTH) self.search_and_replace_cb.setToolTip(prefs.SEARCH_AND_REPLACE_TOOLTIP) self.find.setDisabled(True) self.find.setMinimumWidth(prefs.FIND_WIDTH) self.find.setMaximumWidth(prefs.FIND_WIDTH) self.replace.setDisabled(True) self.replace.setMaximumWidth(prefs.REPLACE_WIDTH) self.replace.setMinimumWidth(prefs.REPLACE_WIDTH) self.renumber_cb.setToolTip(prefs.RENUMBER_TOOLTIP) self.start_num.setToolTip(prefs.START_NUM_TOOLTIP) self.start_num.setDisabled(True) self.start_num.setValue(prefs.START_NUM_DEFAULT) self.start_num.setMinimumWidth(prefs.START_NUM_MIN_WIDTH) self.padding.setToolTip(prefs.PADDING_TOOLTIP) self.padding.setDisabled(True) self.padding.addItems([str(x) for x in range(10)]) self.padding.setCurrentIndex(4) self.padding.setMinimumWidth(prefs.PADDING_MIN_WIDTH) self.dot_cb.setToolTip(prefs.USE_DOT_TOOLTIP) self.dot_cb.setDisabled(True) self.dot_cb.setChecked(True) self.dot_cb.setMinimumWidth(prefs.DOT_WIDTH) self.dot_cb.setMaximumWidth(prefs.DOT_WIDTH) self.remove_ext_cb.setToolTip(prefs.REMOVE_EXT_TOOLTIP) self.change_ext.setToolTip(prefs.CHANGE_EXT_TOOLTIP) self.change_ext.setDisabled(True) self.backup_files_cb.setToolTip(prefs.BACKUP_TOOLTIP) self.backup_files_cb.setChecked(True) self.preview_cb.setToolTip(prefs.PREVIEW_TOOLTIP) self.preview_cb.setChecked(True) self.prefix_h_layout.addWidget(self.add_prefix_cb) self.prefix_h_layout.addWidget(self.prefix) self.frame_layout.addLayout(self.prefix_h_layout) self.complete_rename_h_layout.addWidget(self.complete_rename_cb) self.complete_rename_h_layout.addWidget(self.new_name) self.frame_layout.addLayout(self.complete_rename_h_layout) self.search_and_replace_h_layout.addWidget(self.search_and_replace_cb) self.search_and_replace_h_layout.addWidget(self.find) self.search_and_replace_h_layout.addWidget(self.replace) self.frame_layout.addLayout(self.search_and_replace_h_layout) self.renumber_h_layout.addWidget(self.renumber_cb) self.renumber_h_layout.addStretch(1) self.renumber_h_layout.addWidget(self.start_lbl) self.renumber_h_layout.addWidget(self.start_num) self.renumber_h_layout.addSpacerItem(QSpacerItem(*prefs.SPACER_SIZE)) self.renumber_h_layout.addWidget(self.padding_lbl) self.renumber_h_layout.addWidget(self.padding) self.renumber_h_layout.addSpacerItem(QSpacerItem(*prefs.SPACER_SIZE)) self.renumber_h_layout.addWidget(self.dot_cb) self.frame_layout.addLayout(self.renumber_h_layout) self.change_ext_h_layout.addWidget(self.change_ext_cb) self.change_ext_h_layout.addWidget(self.change_ext) self.frame_layout.addLayout(self.change_ext_h_layout) self.remove_ext_h_layout.addWidget(self.remove_ext_cb) self.frame_layout.addLayout(self.remove_ext_h_layout) self.create_backup_h_layout.addWidget(self.backup_files_cb) self.frame_layout.addLayout(self.create_backup_h_layout) self.preview_h_layout.addWidget(self.preview_cb) self.frame_layout.addLayout(self.preview_h_layout) self.frame_layout.addSpacerItem(QSpacerItem(*prefs.SPACER_SIZE)) self.setLayout(self.layout) def disable_change_ext(self) -> None: """Disable change extension.""" self.change_ext.setDisabled(True) def disable_dot(self) -> None: """Disable dot checkbox.""" self.dot_cb.setDisabled(True) def disable_find(self) -> None: """Disable find.""" self.find.setDisabled(True) def disable_new_name(self) -> None: """Disable new name.""" print("disable new name") self.new_name.setDisabled(True) def disable_padding(self) -> None: """Disable padding.""" self.padding.setDisabled(True) def disable_prefix(self) -> None: """Disable prefix.""" self.prefix.setDisabled(True) def disable_start_num(self) -> None: """Disable start num.""" self.start_num.setDisabled(True) def disable_replace(self) -> None: """Disable replace.""" self.replace.setDisabled(True) def enable_change_ext(self) -> None: """Disable change extension.""" self.change_ext.setDisabled(False) def enable_dot(self) -> None: """Enable dot checkbox.""" self.dot_cb.setEnabled(True) def enable_find(self) -> None: """Enable find.""" self.find.setEnabled(True) def enable_new_name(self) -> None: """Enable new name.""" print("enable new name.") self.new_name.setEnabled(True) def enable_padding(self) -> None: """Enable padding.""" self.padding.setEnabled(True) def enable_prefix(self) -> None: """Enable prefix.""" self.prefix.setEnabled(True) def enable_replace(self) -> None: """Enable replace.""" self.replace.setEnabled(True) def enable_start_num(self) -> None: """Enable start num.""" self.start_num.setEnabled(True) def get_add_prefix(self) -> bool: """Return if end user wants to add a prefix and it is not the default value.""" result = self.get_prefix_checked() if result and self.get_prefix() == prefs.PREFIX_DEFAULT: result = False return result def get_do_backup(self) -> bool: """Return if end user wants to backup files.""" return self.backup_files_cb.isChecked() def get_change_ext(self) -> bool: """Return if the change extension checkbox is checked.""" return self.change_ext_cb.isChecked() def get_do_complete_rename(self) -> bool: """Get if end user wants to completely rename.""" return self.complete_rename_cb.isChecked() def get_dot(self) -> str: """Return dot string based on end users configuration. Note: If the end user has not enable using dot separators an empty string will be returned. """ return "." if self.get_do_dot() else "" def get_do_dot(self) -> bool: """Return if the end user wants to use dot separators when renaming.""" return self.dot_cb.isChecked() def get_do_change_ext(self) -> bool: """Return if the end user wants to change the extension.""" result = self.change_ext_cb.isChecked() if self.get_new_ext() == prefs.CHANGE_EXT_DEFAULT: return False return result def get_do_padding(self) -> bool: """Return if the end user wants to add padding.""" return False if self.get_padding() == 0 else True def get_do_preview(self) -> bool: """Return if the end user wants to preview changes.""" return self.preview_cb.isChecked() def get_do_rename(self) -> bool: """Return if end user wants to rename the full item and it is not the default value.""" result = self.complete_rename_cb.isChecked() if result and self.get_new_name() == prefs.COMPLETE_RENAME_DEFAULT: result = False return result def get_do_renumber(self) -> bool: """Return if the end user wants to renumber.""" return self.renumber_cb.isChecked() def get_do_search(self) -> bool: """Return if end user wants to perform a search and replace AND it is not the default values respectfully. Note: If you only want to know if search and replace is checked use get_search_and_replace. """ result = self.search_and_replace_cb.isChecked() if result and (self.get_find() == prefs.SEARCH_AND_REPLACE_DEFAULT or self.get_replace() == prefs.REPLACE_WITH_DEFAULT): result = False return result def get_do_search_and_replace(self) -> bool: """Return if end user wants to perform a search and replace.""" return self.search_and_replace_cb.isChecked() def get_find(self) -> str: """Return find value.""" return str(self.find.text()) def get_new_ext(self) -> str: """Return new ext.""" return str(self.change_ext.text()) def get_new_name(self) -> str: """Return new_name value.""" return str(self.new_name.text()) def get_padding(self) -> int: """Return the current padding value.""" return int(self.padding.currentText()) def get_prefix_checked(self) -> bool: """Return if the prefix checkbox is checked.""" return self.add_prefix_cb.isChecked() def get_prefix(self) -> str: """Return the current prefix value end user has entered.""" return str(self.prefix.text()) def get_remove_ext(self) -> bool: """Return if end user has checked the remove extension checkbox.""" return self.remove_ext_cb.isChecked() def get_replace(self) -> str: """Return the current replace value end user has entered.""" return str(self.replace.text()) def get_start_num(self) -> int: """Return start number from view.""" return int(self.start_num.value()) def set_change_ext_style(self, style: str) -> None: """Set style of change extension. Args: style: Style sheet applied to change extension. """ self.change_ext.setStyleSheet(style) def set_disabled(self) -> None: """Disable View.""" self.setDisabled(True) def set_enable(self) -> None: """Enable View.""" self.setEnabled(True) def set_find(self, value: str) -> None: """Set the value of find. Args: value: Value applied to find """ self.find.setText(value) def set_find_style(self, style: str) -> None: """Set style of find. Args: style: Style sheet applied to find. """ self.find.setStyleSheet(style) def set_new_name(self, value: str) -> None: """Set the value of new name. Args: value: Value applied to new_name """ self.new_name.setText(value) def set_new_name_style(self, style: str) -> None: """Set style of new_name. Args: style: Style sheet applied to new_name. """ self.new_name.setStyleSheet(style) def set_prefix(self, value: str) -> None: """Set the value of prefix. Args: value: Value applied to prefix """ self.prefix.setText(value) def set_prefix_style(self, style: str) -> None: """Set style of prefix. Args: style: Style sheet applied to prefix. """ self.prefix.setStyleSheet(style) def set_remove_ext(self, state: bool) -> None: """Set the remove_ext checkbox as checked or unchecked. Args: state: Check state of remove_ext. """ self.remove_ext_cb.setCheckState(Qt.Checked if state else Qt.Unchecked) def set_replace(self, value: str) -> None: """Set the value of replace. Args: value: Value applied to replace """ self.replace.setText(value) def set_replace_style(self, style: str) -> None: """Set style of replace. Args: style: Style sheet applied to replace. """ self.replace.setStyleSheet(style)
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 -------------")