def __init__(self, chb_names, parent=None): """Set up the ui and create connections.""" super().__init__(parent) self.setWindowTitle(_QCoreApplication.translate('', "Select Tabs")) self.resize(250, 400) self.setFont(_font) main_layout = _QVBoxLayout() vertical_layout = _QVBoxLayout() group_box = _QGroupBox( _QCoreApplication.translate('', "Select Tabs to Show")) group_box.setLayout(vertical_layout) group_box.setFont(_font_bold) main_layout.addWidget(group_box) self.setLayout(main_layout) self.chb_names = chb_names for name in self.chb_names: name_split = name.split('_') label = ' '.join([s.capitalize() for s in name_split]) chb = _QCheckBox(_QCoreApplication.translate('', label)) setattr(self, 'chb_' + name, chb) vertical_layout.addWidget(chb) chb.setFont(_font) self.pbt_apply = _QPushButton( _QCoreApplication.translate('', "Apply Changes")) self.pbt_apply.setMinimumSize(_QSize(0, 40)) self.pbt_apply.setFont(_font_bold) vertical_layout.addWidget(self.pbt_apply) self.pbt_apply.clicked.connect(self.emit_tab_selection_signal)
def __init__(self, parent=None): """Set up the ui and signal/slot connections.""" super().__init__(parent=parent) # add configure button self.pbt_configure = _QPushButton( _QCoreApplication.translate('', 'Configure Device')) self.pbt_configure.clicked.connect(self.configure_devices) self.add_widgets_next_to_table(self.pbt_configure) # Create reading thread self.wthread = _QThread() self.worker = ReadValueWorker() self.worker.moveToThread(self.wthread) self.wthread.started.connect(self.worker.run) self.worker.finished.connect(self.wthread.quit) self.worker.finished.connect(self.get_reading)
def __init__(self, parent=None): """Add table widget and copy button.""" super().__init__(parent) self.setFont(_font) self.setWindowTitle(_QCoreApplication.translate('', "Statistics")) self.tbl_results = _QTableWidget() self.tbl_results.setAlternatingRowColors(True) self.tbl_results.horizontalHeader().setStretchLastSection(True) self.tbl_results.horizontalHeader().setDefaultSectionSize(120) self.pbt_copy = _QPushButton( _QCoreApplication.translate('', "Copy to clipboard")) self.pbt_copy.clicked.connect(self.copy_to_clipboard) self.pbt_copy.setFont(_font_bold) _layout = _QVBoxLayout() _layout.addWidget(self.tbl_results) _layout.addWidget(self.pbt_copy) self.setLayout(_layout) self.table_df = None self.resize(500, 200)
def add_widgets(self): """Add widgets and layouts.""" # Layouts self.vertical_layout_1 = _QVBoxLayout() self.vertical_layout_2 = _QVBoxLayout() self.vertical_layout_2.setSpacing(20) self.vertical_layout_3 = _QVBoxLayout() self.horizontal_layout_1 = _QHBoxLayout() self.horizontal_layout_2 = _QHBoxLayout() self.horizontal_layout_3 = _QHBoxLayout() self.horizontal_layout_4 = _QHBoxLayout() # Plot Widget self.pw_plot = _pyqtgraph.PlotWidget() brush = _QBrush(_QColor(255, 255, 255)) brush.setStyle(_Qt.NoBrush) self.pw_plot.setBackgroundBrush(brush) self.pw_plot.setForegroundBrush(brush) self.horizontal_layout_1.addWidget(self.pw_plot) # Read button self.pbt_read = _QPushButton(_QCoreApplication.translate('', "Read")) self.pbt_read.setMinimumSize(_QSize(0, 45)) self.pbt_read.setFont(_font_bold) self.vertical_layout_2.addWidget(self.pbt_read) # Monitor button self.pbt_monitor = _QPushButton( _QCoreApplication.translate('', "Monitor")) self.pbt_monitor.setMinimumSize(_QSize(0, 45)) self.pbt_monitor.setFont(_font_bold) self.pbt_monitor.setCheckable(True) self.pbt_monitor.setChecked(False) self.vertical_layout_2.addWidget(self.pbt_monitor) # Monitor frequency label = _QLabel(_QCoreApplication.translate('', "Frequency [Hz]:")) label.setAlignment(_Qt.AlignRight | _Qt.AlignTrailing | _Qt.AlignVCenter) self.horizontal_layout_3.addWidget(label) self.sbd_monitor_freq = _QDoubleSpinBox() self.sbd_monitor_freq.setDecimals(2) self.sbd_monitor_freq.setMinimum(0.01) self.sbd_monitor_freq.setMaximum(100.00) self.sbd_monitor_freq.setProperty("value", 1) self.horizontal_layout_3.addWidget(self.sbd_monitor_freq) self.vertical_layout_2.addLayout(self.horizontal_layout_3) # Group box with read and monitor buttons self.group_box = _QGroupBox() self.group_box.setMinimumSize(_QSize(270, 0)) self.group_box.setTitle("") self.group_box.setLayout(self.vertical_layout_2) # Table widget self.tbl_table = _QTableWidget() sizePolicy = _QSizePolicy(_QSizePolicy.Expanding, _QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.tbl_table.sizePolicy().hasHeightForWidth()) self.tbl_table.setSizePolicy(sizePolicy) self.tbl_table.setVerticalScrollBarPolicy(_Qt.ScrollBarAlwaysOn) self.tbl_table.setHorizontalScrollBarPolicy(_Qt.ScrollBarAsNeeded) self.tbl_table.setEditTriggers(_QAbstractItemView.NoEditTriggers) self.tbl_table.setColumnCount(0) self.tbl_table.setRowCount(0) self.tbl_table.horizontalHeader().setVisible(True) self.tbl_table.horizontalHeader().setCascadingSectionResizes(False) self.tbl_table.horizontalHeader().setDefaultSectionSize(200) self.tbl_table.horizontalHeader().setHighlightSections(True) self.tbl_table.horizontalHeader().setMinimumSectionSize(80) self.tbl_table.horizontalHeader().setStretchLastSection(True) self.tbl_table.verticalHeader().setVisible(False) self.horizontal_layout_4.addWidget(self.tbl_table) # Tool buttons self.tbt_autorange = _QToolButton() self.tbt_autorange.setIcon(_utils.get_icon(_autorange_icon_file)) self.tbt_autorange.setIconSize(_icon_size) self.tbt_autorange.setCheckable(True) self.tbt_autorange.setToolTip( _QCoreApplication.translate('', 'Turn on plot autorange.')) self.vertical_layout_3.addWidget(self.tbt_autorange) self.tbt_save = _QToolButton() self.tbt_save.setIcon(_utils.get_icon(_save_icon_file)) self.tbt_save.setIconSize(_icon_size) self.tbt_save.setToolTip( _QCoreApplication.translate('', 'Save table data to file.')) self.vertical_layout_3.addWidget(self.tbt_save) self.tbt_copy = _QToolButton() self.tbt_copy.setIcon(_utils.get_icon(_copy_icon_file)) self.tbt_copy.setIconSize(_icon_size) self.tbt_copy.setToolTip( _QCoreApplication.translate('', 'Copy table data.')) self.vertical_layout_3.addWidget(self.tbt_copy) self.pbt_stats = _QToolButton() self.pbt_stats.setIcon(_utils.get_icon(_stats_icon_file)) self.pbt_stats.setIconSize(_icon_size) self.pbt_stats.setToolTip( _QCoreApplication.translate('', 'Show data statistics.')) self.vertical_layout_3.addWidget(self.pbt_stats) self.pbt_remove = _QToolButton() self.pbt_remove.setIcon(_utils.get_icon(_delete_icon_file)) self.pbt_remove.setIconSize(_icon_size) self.pbt_remove.setToolTip( _QCoreApplication.translate('', 'Remove selected lines from table.')) self.vertical_layout_3.addWidget(self.pbt_remove) self.tbt_clear = _QToolButton() self.tbt_clear.setIcon(_utils.get_icon(_clear_icon_file)) self.tbt_clear.setIconSize(_icon_size) self.tbt_clear.setToolTip( _QCoreApplication.translate('', 'Clear table data.')) self.vertical_layout_3.addWidget(self.tbt_clear) spacer_item = _QSpacerItem(20, 100, _QSizePolicy.Minimum, _QSizePolicy.Fixed) self.vertical_layout_3.addItem(spacer_item) self.horizontal_layout_4.addLayout(self.vertical_layout_3) self.horizontal_layout_2.addWidget(self.group_box) self.horizontal_layout_2.addLayout(self.horizontal_layout_4) self.vertical_layout_1.addLayout(self.horizontal_layout_1) self.vertical_layout_1.addLayout(self.horizontal_layout_2) self.setLayout(self.vertical_layout_1)