Example #1
0
 def __init__(self, color: str = None, parent: QtGui.QWidget = None):
     self.color = None
     super().__init__(parent)
     self.select_button = create_button(
         _("Choose a color…"), min_size=True, connect=self.select_color, icon="preferences-color"
     )
     self.line_editor = QtGui.QLineEdit(p(self))
     self.line_editor.setValidator(self.validator)
     if not color or not COLOR_RE.match(color):
         color = None
     self.set_value(color)
     layout = h_layout(self, self.select_button, self.line_editor)
     self.setLayout(layout)
     self.adjustSize()
Example #2
0
 def get_value(self):
     color = self.line_editor.text()
     if not COLOR_RE.match(color):
         return None
     return color
Example #3
0
 def set_value(self, color: str = None):
     if not color or not COLOR_RE.match(color):
         color = None
     self.color = color
     self.line_editor.setText("" if not color else color.upper())