From a5123bfab06f7fd8884b9b4f12f579dceec43aa1 Mon Sep 17 00:00:00 2001 From: yo mama Date: Wed, 11 Mar 2015 02:51:58 -0700 Subject: finished OOP rewrite --- Pb_Api/Param/Color.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'Pb_Api/Param/Color.py') diff --git a/Pb_Api/Param/Color.py b/Pb_Api/Param/Color.py index 1c14c8d..678a087 100644 --- a/Pb_Api/Param/Color.py +++ b/Pb_Api/Param/Color.py @@ -7,10 +7,19 @@ class Pb_Api_Param_Color(Pb_Api_Param_MultiSelect): @classmethod def from_rgb(cls, r,g,b): return cls(value="rgb({},{},{})".format(r,g,b)) - + + @property + def value(self): + return super(Pb_Api_Param_MultiSelect, self).get_value() + @value.setter + def value(self, value): + self._value = value + if not self._value is None: + self.is_ready = 1 + self.set_by_user = 1 def randomize(self): - weights_total = sum(map(lambda x: x["weight"], self.options()) + (255 * 255 * 255) + weights_total = sum(map(lambda x: x["weight"], self.options())) + (255 * 255 * 255) choice = random.randint(0, weights_total) position = 0 for elem in self.options(): @@ -18,8 +27,4 @@ class Pb_Api_Param_Color(Pb_Api_Param_MultiSelect): if position >= choice: self.value = elem["value"] return - self.value = "rgb({},{},{})".format( - random.randint(0,255), - random.randint(0,255), - random.randint(0,255), - ) + self.value = "rgb({},{},{})".format( random.randint(0,255), random.randint(0,255), random.randint(0,255)) -- cgit v1.2.3-70-g09d2