def __init__(self, wib_server='127.0.0.1', cli=False): super().__init__() self.cli = cli self.wib = WIB(wib_server) self.setAutoFillBackground(True) p = self.palette() p.setColor(self.backgroundRole(), QtGui.QColor(*colors[0])) self.setPalette(p) self._main = QtWidgets.QWidget() self.setCentralWidget(self._main) layout = QtWidgets.QVBoxLayout(self._main) self.wib_pane = WIBPane(self) self.femb_panes = [FEMBPane(self, idx) for idx in range(4)] layout.addWidget(self.wib_pane) fembs = QtWidgets.QWidget(self._main) fembs_layout = QtWidgets.QGridLayout(fembs) for idx, f in enumerate(self.femb_panes): fembs_layout.addWidget(f, idx // 2, idx % 2) layout.addWidget(fembs) if self.cli: self.get_sensors() else: QtCore.QTimer.singleShot(500, self.get_sensors)
def set_marking_label(self, label): logging.debug('Setting marking label to %s %s', self, label) color = QtGui.QColor(LABEL_COLOR_MAP.get(label, 'white')) color.setAlphaF(SPAN_ALPHA) self.marking_label.setStyleSheet( "background-color: rgba{};".format(tuple(color.getRgb())) ) self.marking_label.setText('Current label-mode: {}'.format(label)) self.model.set_current_label(label)
def to_qcolor(color): """Create a QColor from a matplotlib color""" qcolor = QtGui.QColor() try: rgba = mcolors.to_rgba(color) except ValueError: cbook._warn_external('Ignoring invalid color %r' % color) return qcolor # return invalid QColor qcolor.setRgbF(*rgba) return qcolor
def to_qcolor(color): """Create a QColor from a matplotlib color""" qcolor = QtGui.QColor() try: rgba = mcolors.to_rgba(color) except ValueError: warnings.warn('Ignoring invalid color %r' % color, stacklevel=2) return qcolor # return invalid QColor qcolor.setRgbF(*rgba) return qcolor
def to_qcolor(color): """Create a QColor from a matplotlib color""" qcolor = QtGui.QColor() color = str(color) try: color = col2hex(color) except ValueError: #print('WARNING: ignoring invalid color %r' % color) return qcolor # return invalid QColor qcolor.setNamedColor(color) # set using hex color return qcolor # return valid QColor
def _icon(self, name, color=None): if is_pyqt5(): name = name.replace('.png', '_large.png') pm = QtGui.QPixmap(os.path.join(self.basedir, name)) if hasattr(pm, 'setDevicePixelRatio'): pm.setDevicePixelRatio(self.canvas._dpi_ratio) if color is not None: mask = pm.createMaskFromColor(QtGui.QColor('black'), QtCore.Qt.MaskOutColor) pm.fill(color) pm.setMask(mask) return QtGui.QIcon(pm)
def __init__(self, parent=None): QtWidgets.QPushButton.__init__(self, parent) self.setFixedSize(20, 20) self.setIconSize(QtCore.QSize(12, 12)) self.clicked.connect(self.choose_color) self._color = QtGui.QColor()
def add_dataitem(self, series, name=None, metadata=None): """ Add dataitem to model Parameters ---------- series : pandas.Series name : object | str | None """ row_idx = min(len(self.items), len(COLORS)) if self.items else 0 if not isinstance(series, pd.Series): logger.error('Cannot add item of type {}: {}' ''.format(type(series), str(series)[:100])) return if name is None: if series.name is None: name = '{} - {}'.format(COLORS[row_idx], len(series)) logger.warn('Found no name for series, using color and ' 'number of values: "{}"'.format(name)) else: series.name = str(series.name) name = series.name name = str(name) if series.empty: logger.error('series {} is empty, cannot add to view'.format(name)) return # Set xaxis_unit variable if this is the first data ever added if self.total_items_ever_added == 0: if isinstance(series.index, pd.DatetimeIndex): self.xaxis_unit = XAXIS_TIME else: self.xaxis_unit = XAXIS_NUMBER if isinstance(series.index, pd.DatetimeIndex): if not self.xaxis_unit_is_time(): logger.warning("Cannot add series with datetimeindex when " "x-axis type is not datetime") return elif self.xaxis_unit_is_time(): logger.warning("Cannot add series without datetimeindex when " "x-axis type is datetime") return # NOTE: Item color examples: http://ynonperek.com/q.t-mvc-customize-items item_color = QtGui.QColor(COLORS[row_idx]) item_color.setAlphaF(DATA_ALPHA) item = DataItem(series, name, metadata=metadata) item.setCheckState(Qt.Checked) item.setCheckable(True) self.items.append(item) self.total_items_ever_added += 1 colorpatch_item = QtGui.QStandardItem('') colorpatch_item.setData(QtGui.QBrush(item_color), Qt.BackgroundColorRole) self.item_model.setItem(row_idx, 0, colorpatch_item) self.item_model.setItem(row_idx, 1, item) self.sig_item_added.emit(item)
def __init__(self, parent=None): super().__init__(parent) self.setFixedSize(20, 20) self.setIconSize(QtCore.QSize(12, 12)) self.clicked.connect(self.choose_color) self._color = QtGui.QColor()
def set_color(self, r, g, b): p = self.palette() p.setColor(self.backgroundRole(), QtGui.QColor(r, g, b)) self.setPalette(p)
def __init__(self, parent): super().__init__('WIB', parent) self.setAutoFillBackground(True) p = self.palette() p.setColor(self.backgroundRole(), QtGui.QColor(*colors[0])) self.setPalette(p) self.setStyleSheet('QGroupBox { font-weight: bold; color: #cb4b16; } ') self.t_sensors = [] self.t_sensors.append( TSensor(self, 'Board Temp 1', lambda s: s.ad7414_49_temp)) self.t_sensors.append( TSensor(self, 'Board Temp 2', lambda s: s.ad7414_4d_temp)) self.t_sensors.append( TSensor(self, 'Board Temp 3', lambda s: s.ad7414_4a_temp)) self.t_sensors.append(TSensor(self, 'DDR Temp', lambda s: nan)) #FIXME self.t_sensors.append( VTSensor(self, 'Power Temp 1', lambda s: s.ltc2499_15_temps[4])) self.t_sensors.append( VTSensor(self, 'Power Temp 2', lambda s: s.ltc2499_15_temps[5])) self.t_sensors.append( VTSensor(self, 'Power Temp 3', lambda s: s.ltc2499_15_temps[6])) self.iv_sensors = [] self.iv_sensors.append( IVSensor(self, 'WIB 5 V', lambda s: s.ltc2990_4e_voltages[0:2], sense_ohms=0.001)) self.iv_sensors.append( IVSensor(self, 'WIB 1.2 V', lambda s: s.ltc2990_4c_voltages[0:2], sense_ohms=0.001)) self.iv_sensors.append( IVSensor(self, 'WIB 3.3 V', lambda s: s.ltc2990_4c_voltages[2:4], sense_ohms=0.001)) self.iv_sensors.append( IVSensor(self, 'WIB 0.85 V', lambda s: s.ltc2991_48_voltages[0:2], sense_ohms=0.001)) self.iv_sensors.append( IVSensor(self, 'WIB 0.9 V', lambda s: s.ltc2991_48_voltages[2:4], sense_ohms=0.001)) self.iv_sensors.append( IVSensor(self, 'WIB 2.5 V', lambda s: s.ltc2991_48_voltages[4:6], sense_ohms=0.001)) self.iv_sensors.append( IVSensor(self, 'WIB 1.8 V', lambda s: s.ltc2991_48_voltages[6:8], sense_ohms=0.001)) layout = QtWidgets.QGridLayout(self) for i, t in enumerate(self.t_sensors): layout.addWidget(t, 0, i) for i, t in enumerate(self.iv_sensors): layout.addWidget(t, 1, i)
def __init__(self, parent, idx): super().__init__('FEMB%i' % idx, parent) self.idx = idx self.setAutoFillBackground(True) p = self.palette() p.setColor(self.backgroundRole(), QtGui.QColor(*colors[0])) self.setPalette(p) self.setStyleSheet('QGroupBox { font-weight: bold; color: #cb4b16; } ') self.tpower_sensor = VTSensor(self, 'Power Temp', lambda s: s.ltc2499_15_temps[self.idx]) self.iv_sensors = [] self.iv_sensors.append( IVSensor( self, 'LDO A0', lambda s: s.femb_ldo_a0_ltc2991_voltages[self.idx * 2: (self.idx + 1) * 2], sense_ohms=0.01, disabled=True)) self.iv_sensors.append( IVSensor( self, 'LDO A1', lambda s: s.femb_ldo_a1_ltc2991_voltages[self.idx * 2: (self.idx + 1) * 2], sense_ohms=0.01, disabled=True)) self.iv_sensors.append( IVSensor( self, '5V Bias', lambda s: s.femb_bias_ltc2991_voltages[self.idx * 2: (self.idx + 1) * 2], sense_ohms=0.1)) self.iv_sensors.append( IVSensor(self, 'DC/DC V1', lambda s: dc2dc(s, self.idx)[0:2], sense_ohms=0.1)) self.iv_sensors.append( IVSensor(self, 'DC/DC V2', lambda s: dc2dc(s, self.idx)[2:4], sense_ohms=0.1)) self.iv_sensors.append( IVSensor(self, 'DC/DC V3', lambda s: dc2dc(s, self.idx)[4:6], sense_ohms=0.01)) self.iv_sensors.append( IVSensor(self, 'DC/DC V4', lambda s: dc2dc(s, self.idx)[6:8], sense_ohms=0.1)) layout = QtWidgets.QGridLayout(self) layout.addWidget(self.tpower_sensor, 0, 0) for i, t in enumerate(self.iv_sensors): layout.addWidget(t, (i + 1) // 4, (i + 1) % 4)