Ejemplo n.º 1
0
    def _select(self, nbr):
        col = QtGui.QColor()  # default to invalid

        if self._mem:
            led = self._mem.leds[nbr]
            col = QtGui.QColor.fromRgb(led.r, led.g, led.b)

        col = QtGui.QColorDialog.getColor(col)

        if col.isValid() and self._mem:
            logger.info(col.red())
            self._mem.leds[nbr].set(r=col.red(), g=col.green(), b=col.blue())
            UiUtils.set_background_color(self.sender(), col.red(), col.green(),
                                         col.blue())
            self._write_led_output()
Ejemplo n.º 2
0
 def _theme_selected(self, *args):
     """ Callback when a theme is selected. """
     for checkbox in self._theme_checkboxes:
         if checkbox.isChecked():
             theme = checkbox.objectName()
             app = QtWidgets.QApplication.instance()
             app.setStyleSheet(UiUtils.select_theme(theme))
             Config().set('theme', theme)
Ejemplo n.º 3
0
    def _update_battery(self, timestamp, data, logconf):
        self.batteryBar.setValue(int(data["pm.vbat"] * 1000))

        color = UiUtils.COLOR_BLUE
        # TODO firmware reports fully-charged state as 'Battery',
        # rather than 'Charged'
        if data["pm.state"] in [BatteryStates.CHARGING, BatteryStates.CHARGED]:
            color = UiUtils.COLOR_GREEN
        elif data["pm.state"] == BatteryStates.LOW_POWER:
            color = UiUtils.COLOR_RED

        self.batteryBar.setStyleSheet(UiUtils.progressbar_stylesheet(color))
        self._aff_volts.setText(("%.3f" % data["pm.vbat"]))
Ejemplo n.º 4
0
    def updatePacketSizeBar(self):
        self.currentSize = 0
        for node in self.getNodeChildren(self.varTree.invisibleRootItem()):
            for leaf in self.getNodeChildren(node):
                self.currentSize = (self.currentSize +
                                    int(leaf.text(SIZE_FIELD)))

        self.packetSizeText.setText('%s/%s bytes' % (self.currentSize,
                                                     MAX_LOG_SIZE))

        if self.currentSize > MAX_LOG_SIZE:
            self.packetSize.setMaximum(self.currentSize / MAX_LOG_SIZE * 100)
            self.packetSize.setFormat("%v%")
            self.packetSize.setValue(self.currentSize / MAX_LOG_SIZE * 100)
            self.packetSize.setStyleSheet(
                        UiUtils.progressbar_stylesheet('red'))
        else:
            self.packetSize.setMaximum(MAX_LOG_SIZE)
            self.packetSize.setFormat("%p%")
            self.packetSize.setValue(self.currentSize)
            self.packetSize.setStyleSheet(
                        UiUtils.progressbar_stylesheet(UiUtils.COLOR_GREEN))