Exemplo n.º 1
0
 def propertyUpdated(self, pname, value):
     if pname == 'dev':
         if value:
             self.key = value + '.value'
             self.statuskey = value + '.status'
     elif pname == 'width':
         if value < 0:
             self.reinitLayout()
         else:
             onechar = QFontMetrics(self.valueFont).width('0')
             self.valuelabel.setMinimumSize(QSize(onechar * (value + .5), 0))
     elif pname == 'istext':
         self.valuelabel.setFont(value and self.font() or self.valueFont)
         self.width = self.width
     elif pname == 'valueFont':
         self.valuelabel.setFont(self.valueFont)
         self.width = self.width  # update char width calculation
     elif pname == 'showName':
         self.namelabel.setVisible(value)
     elif pname == 'showStatus':
         if not value:
             setBothColors(self.valuelabel,
                           (self._colorscheme['fore'][UNKNOWN],
                            self._colorscheme['back'][UNKNOWN]))
     elif pname == 'horizontal':
         self.reinitLayout()
     if pname in ('dev', 'name', 'unit'):
         self.update_namelabel()
     NicosWidget.propertyUpdated(self, pname, value)
Exemplo n.º 2
0
 def _applystatuscolor(self):
     if self._expired:
         setBothColors(self.valuelabel, (self._colorscheme['fore'][UNKNOWN],
                                         self._colorscheme['expired']))
     else:
         setBothColors(self.valuelabel, self._statuscolors)
         if self._labelcolor:
             self.namelabel.setAutoFillBackground(True)
             setBackgroundColor(self.namelabel, self._labelcolor)
         else:
             self.namelabel.setAutoFillBackground(False)
Exemplo n.º 3
0
    def initUi(self):
        self.namelabel = QLabel(' ', self, textFormat=Qt.RichText)
        self.update_namelabel()

        valuelabel = SensitiveSMLabel('----', self, self._label_entered,
                                      self._label_left)
        valuelabel.setFrameShape(QFrame.Panel)
        valuelabel.setAlignment(Qt.AlignHCenter)
        valuelabel.setFrameShadow(QFrame.Sunken)
        valuelabel.setAutoFillBackground(True)
        setBothColors(valuelabel, (self._colorscheme['fore'][UNKNOWN],
                                   self._colorscheme['back'][UNKNOWN]))
        valuelabel.setLineWidth(2)
        self.valuelabel = valuelabel
        self.width = 8

        self.reinitLayout()
Exemplo n.º 4
0
 def on_devValueChange(self, dev, value, strvalue, unitvalue, expired):
     # check expired values
     self._expired = expired
     self._lastvalue = value
     self._lastchange = currenttime()
     if self.props['maxlen'] > -1:
         self.valuelabel.setText(strvalue[:self.props['maxlen']])
     else:
         self.valuelabel.setText(strvalue)
     if self._expired:
         setBothColors(self.valuelabel, (self._colorscheme['fore'][UNKNOWN],
                                         self._colorscheme['expired']))
         if self.props['showExpiration']:
             self.valuelabel.setText(NOT_AVAILABLE)
     elif not self.props['istext']:
         setBothColors(self.valuelabel, (self._colorscheme['fore'][BUSY],
                                         self._colorscheme['back'][BUSY]))
         QTimer.singleShot(1000, self._applystatuscolor)
     else:
         self._applystatuscolor()