1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
from ricky.param import Param import random class Color(Param): def __init__(self, **kwargs): super(Color, self).__init__(**kwargs) @classmethod def from_rgb(cls, r, g, b): return cls(value="rgb({},{},{})".format(r, g, b)) def randomize(self): self.value = "rgb(%s,%s,%s)" % ( random.randint(0, 255), random.randint(0, 255), random.randint(0, 255) )