def __init__(self, varsets, elements=None, normal_params=None, size=None, bar=None, file_width=None, finish=True): if file_width is None: file_width = style.FILE_WIDTH ## box_size = style.BOX_SIZE if box_size is None else box_size self.scale_list = [DropDownListLauncher] #!paramsetter self.varsets = varsets if not isinstance(self.varsets, list): self.varsets = [self.varsets] self.handlers = self.get_handlers( ) #below, will deny them so they know self elements = [] if elements is None else elements elements += self.handlers.values() Box.__init__(self, elements=elements, normal_params=normal_params, size=size, finish=False) if finish: self.finish()
def __init__(self, text="", elements=None, normal_params=None, storer_params=None, size=None, put_lift=True, color_size=(50, 50), value=(255, 0, 0), color_limvals=(0, 255)): Box.__init__(self, text, elements, normal_params, storer_params, size, put_lift) self._color_size = color_size self._r_element = SliderXSetter(100, text="R: ", typ=int, limvals=color_limvals, initial_value=value[0]) self._r_element.finish() self._g_element = SliderXSetter(100, text="G: ", typ=int, limvals=color_limvals, initial_value=value[1]) self._g_element.finish() self._b_element = SliderXSetter(100, text="B: ", typ=int, limvals=color_limvals, initial_value=value[2]) self._b_element.finish() reac_red = ConstantReaction(constants.THORPY_EVENT, self.refresh, { "name": constants.EVENT_SLIDE, "el": self._r_element }, name="setcolorred") reac_green = ConstantReaction(constants.THORPY_EVENT, self.refresh, { "name": constants.EVENT_SLIDE, "el": self._g_element }, name="setcolorgreen") reac_blue = ConstantReaction(constants.THORPY_EVENT, self.refresh, { "name": constants.EVENT_SLIDE, "el": self._b_element }, name="setcolorblue") self.add_reactions([reac_red, reac_green, reac_blue]) self._example_element = self._get_example_element() self.add_elements([ self._r_element, self._g_element, self._b_element, self._example_element ])
def __init__(self, text="", elements=None, normal_params=None, storer_params=None, size=None, put_lift=True, color_size=(50, 50), value=(255, 0, 0), color_limvals=(0, 255)): """Box in which three sliders and a visualization square provide a way to define a color. <text>: title text for the color box. <size>: if not None, force the size of the box. <color_size>: the size of the color visualization rect. <value>: 3-tuple defining the initial color value. """ Box.__init__(self, elements, normal_params, storer_params, size, put_lift) self._color_size = color_size self._r_element = SliderXSetter(100, text="R: ", type_=int, limvals=color_limvals, initial_value=value[0]) self._r_element.finish() self._g_element = SliderXSetter(100, text="G: ", type_=int, limvals=color_limvals, initial_value=value[1]) self._g_element.finish() self._b_element = SliderXSetter(100, text="B: ", type_=int, limvals=color_limvals, initial_value=value[2]) self._b_element.finish() reac_red= ConstantReaction(constants.THORPY_EVENT, self.refresh, {"id":constants.EVENT_SLIDE, "el":self._r_element}, reac_name="setcolorred") reac_green= ConstantReaction(constants.THORPY_EVENT, self.refresh, {"id":constants.EVENT_SLIDE, "el":self._g_element}, reac_name="setcolorgreen") reac_blue= ConstantReaction(constants.THORPY_EVENT, self.refresh, {"id":constants.EVENT_SLIDE, "el":self._b_element}, reac_name="setcolorblue") self.add_reactions([reac_red, reac_green, reac_blue]) self._example_element = get_example_element(value, color_size) self.add_elements([self._r_element, self._g_element, self._b_element, self._example_element])
def __init__(self, varsets, elements=None, normal_params=None, size=None, bar=None, file_width=None): if file_width is None: file_width = style.FILE_WIDTH ## box_size = style.BOX_SIZE if box_size is None else box_size self.scale_list = [DropDownListLauncher] #!paramsetter self.varsets = varsets if not isinstance(self.varsets, list): self.varsets = [self.varsets] self.handlers = self.get_handlers() #below, will deny them so they know self elements = [] if elements is None else elements elements += self.handlers.values() Box.__init__(self, elements=elements, normal_params=normal_params, size=size)
def __init__(self, text="", elements=None, normal_params=None, storer_params=None, size=None, put_lift=True, color_size=(50, 50), value=(255, 0, 0), color_limvals=(0, 255)): Box.__init__(self, text, elements, normal_params, storer_params, size, put_lift) self._color_size = color_size self._r_element = SliderXSetter(100, text="R: ", typ=int, limvals=color_limvals, initial_value=value[0]) self._r_element.finish() self._g_element = SliderXSetter(100, text="G: ", typ=int, limvals=color_limvals, initial_value=value[1]) self._g_element.finish() self._b_element = SliderXSetter(100, text="B: ", typ=int, limvals=color_limvals, initial_value=value[2]) self._b_element.finish() reac_red= ConstantReaction(constants.THORPY_EVENT, self.refresh, {"name" : constants.EVENT_SLIDE, "el": self._r_element}, name="setcolorred") reac_green= ConstantReaction(constants.THORPY_EVENT, self.refresh, {"name" : constants.EVENT_SLIDE, "el": self._g_element}, name="setcolorgreen") reac_blue= ConstantReaction(constants.THORPY_EVENT, self.refresh, {"name" : constants.EVENT_SLIDE, "el": self._b_element}, name="setcolorblue") self.add_reactions([reac_red, reac_green, reac_blue]) self._example_element = self._get_example_element() self.add_elements([self._r_element, self._g_element, self._b_element, self._example_element])