def setStatus(self, status): """Update with the daemon status.""" self.current_status = status if status != 'idle': setBackgroundColor(self, self.run_color) if not self.error_status: setForegroundColor(self, self.inactive_fgcolor) else: setBackgroundColor(self, self.idle_color) if not self.error_status: setForegroundColor(self, self.active_fgcolor) self.update() self.setEnabled(status != 'disconnected')
def on_textChanged(self): setForegroundColor(self, self.active_fgcolor) try: script = self.text() if not script or script.strip().startswith('#'): return compile(script + '\n', 'script', 'single') except Exception: self.error_status = True setForegroundColor(self, self.error_fgcolor) self.update() else: self.error_status = False setForegroundColor(self, self.active_fgcolor)
def on_devValueChange(self, dev, value, strvalue, unitvalue, expired): if expired: setForegroundColor(self, QColor('grey')) else: setForegroundColor(self, QColor('black')) self.setText(self._callback(value, strvalue))
def _setShadow(self): self._shadowed = True QLineEdit.setText(self, self.shadowText) setForegroundColor(self, self._shadowcolor)
def setText(self, text): self._shadowed = False QLineEdit.setText(self, text) setForegroundColor(self, self._textcolor)