def onInit(self): avg.RectNode(size=(1024, 768), fillopacity=1, fillcolor="FFFFFF", parent=self) hScrollBar = widget.ScrollBar(pos=(10, 10), width=150, parent=self) self.__addValueDisplay(hScrollBar, (175, 12)) vScrollBar = widget.ScrollBar(pos=(15, 60), height=150, orientation=widget.Orientation.VERTICAL, parent=self) vScrollBar.thumbExtent = 5 vScrollBar.range = (10, 0) self.__addValueDisplay(vScrollBar, (10, 220)) hSlider = widget.Slider(pos=(10, 35), width=150, parent=self) self.__addValueDisplay(hSlider, (175, 33)) vSlider = widget.Slider(pos=(60.5, 60), height=150, orientation=widget.Orientation.VERTICAL, parent=self) vSlider.range = (1, 0) self.__addValueDisplay(vSlider, (55, 220)) self.controls = [hScrollBar, vScrollBar, hSlider, vSlider] self.createScrollArea(avg.Point2D(220, 10)) checkBox = widget.CheckBox(pos=(10, 270), text="Disable everything", parent=self) checkBox.subscribe(widget.CheckBox.TOGGLED, self.onCheck)
def createScrollArea(self, pos): image = avg.ImageNode(href="rgb24-64x64.png", size=(1024, 1024)) scrollArea = widget.ScrollArea(contentNode=image, parent=self, pos=pos, size=(220, 220)) imageWidthSlider = widget.Slider(pos=pos + (0, 230), width=220, parent=self) imageWidthSlider.range = (100, 1024) imageWidthSlider.thumbPos = 1024 imageWidthSlider.subscribe(widget.ScrollBar.THUMB_POS_CHANGED, lambda thumbPos, scrollArea=scrollArea: self .setImageWidth(scrollArea, thumbPos)) imageHeightSlider = widget.Slider( pos=pos + (230, 0), height=220, orientation=widget.Orientation.VERTICAL, parent=self) imageHeightSlider.range = (100, 1024) imageHeightSlider.thumbPos = 1024 imageHeightSlider.subscribe(widget.ScrollBar.THUMB_POS_CHANGED, lambda thumbPos, scrollArea=scrollArea: self.setImageHeight(scrollArea, thumbPos)) self.controls.extend([scrollArea, imageWidthSlider, imageHeightSlider])
def testSlider(self): def onThumbPosChanged(pos): self.thumbPos = pos def setSize(): if orientation == widget.Orientation.HORIZONTAL: self.node.width = 140 else: self.node.height = 60 sys.stderr.write("\n") for orientation, orName in ((widget.Orientation.HORIZONTAL, "Horiz"), (widget.Orientation.VERTICAL, "Vert")): for widgetType in ("Slider", "TimeSlider"): sys.stderr.write(" " + widgetType + ", " + orName + "\n") root = self.loadEmptyScene() if widgetType == "Slider": self.node = widget.Slider(orientation=orientation, pos=(20, 20), width=100, height=100, parent=root) else: self.node = widget.TimeSlider(orientation=orientation, pos=(20, 20), width=100, height=100, parent=root) self.start(False, ( lambda: self.compareImage("test" + widgetType + orName + "1"), lambda: self.node.setThumbPos(0.25), lambda: self.compareImage("test" + widgetType + orName + "2"), lambda: self.node.setThumbPos(1), lambda: self.compareImage("test" + widgetType + orName + "3"), lambda: self.node.setRange((1, 10)), lambda: self.compareImage("test" + widgetType + orName + "1"), lambda: self.node.setRange((10, 1)), lambda: self.compareImage("test" + widgetType + orName + "3"), setSize, lambda: self.compareImage("test" + widgetType + orName + "4"), lambda: self.node.setEnabled(False), lambda: self.compareImage("test" + widgetType + orName + "5"), lambda: self.node.setEnabled(True), lambda: self.compareImage("test" + widgetType + orName + "4"), ))
def __init__(self, label, sliderRange, formatStr, parent=None, **kwargs): super(LabledSlider, self).__init__(**kwargs) self.registerInstance(self, parent) self.__formatStr = formatStr fontStyle = widget.Skin.default.fonts["stdFont"] avg.WordsNode(text=label, fontstyle=fontStyle, color="FFFFFF", parent=self) self.__slider = widget.Slider(width=300, range=sliderRange, pos=(15,20), parent=self) self.__slider.subscribe(self.__slider.THUMB_POS_CHANGED, self.__onSliderMove) self.__valueDisplay = avg.WordsNode(pos=(320, 18), fontstyle=fontStyle, color="FFFFFF", parent=self) self.__valueDisplay.text = self.__formatStr%self.__slider.thumbPos self.publish(widget.Slider.THUMB_POS_CHANGED)
def __init_smoothness_slider(self): pos = avg.Point2D(self.width - 180, 0) avg.WordsNode(pos=pos + (4, 0), color=global_values.COLOR_FOREGROUND, fontsize=global_values.FONT_SIZE, text="Smoothness", parent=self) smoothness_range = self.__vis_params.MIN_SMOOTHNESS_FACTOR, self.__vis_params.MAX_SMOOTHNESS_FACTOR self.smoothness_slider = widget.Slider(pos=pos + (0, 33), width=180, range=smoothness_range, parent=self) self.smoothness_slider.thumbPos = self.__vis_params.get_smoothness_factor( ) self.smoothness_slider.subscribe(widget.Slider.THUMB_POS_CHANGED, self.__on_smoothness_change)
def __init__(self, row, min, max, fxNode, fxAttrName, caption, isInt, parent=None, **kwargs): super(FXSlider, self).__init__(**kwargs) if parent: parent.appendChild(self) avg.RectNode(pos=(0, 8), size=(280, 38), color="808080", strokewidth=2, parent=self) textBgRect = avg.RectNode(pos=(8, 2), fillcolor="000000", fillopacity=1, strokewidth=0, parent=self) caption = avg.WordsNode(pos=(10, 0), text=caption, parent=self) textBgRect.size = caption.getMediaSize() + (4, 2) self.__words = avg.WordsNode(pos=(240, 23), parent=self) self.__slider = widget.Slider(width=220, range=(min, max), pos=(15, 20), parent=self) self.__slider.subscribe(self.__slider.THUMB_POS_CHANGED, self.__onSliderMove) self.pos = (0, row * 46) self.__fxNode = fxNode self.__fxAttrName = fxAttrName self.__caption = caption self.__isInt = isInt self.__slider.thumbPos = getattr(self.__fxNode, fxAttrName) self.__onSliderMove(self.__slider.thumbPos)
def onInit(self): # images orig = avg.ImageNode(href='../test/media/hsl.png', parent=self) huesat = avg.ImageNode(href='../test/media/hsl.png', pos=(orig.size.x + 10, 0), parent=self) # effect self._fx = avg.HueSatFXNode(colorize=False) huesat.setEffect(self._fx) y = orig.size.y + 10 # hue slider self._hueTxt = avg.WordsNode(text='hue: %d' % self._fx.hue, fontsize=12, pos=(0, y), parent=self) y += self._hueTxt.height self._hueSld = widget.Slider(range=(-180, 180), thumbPos=self._fx.hue, width=self.width, pos=(0, y), parent=self) self._hueSld.subscribe(widget.Slider.THUMB_POS_CHANGED, self._onSliderHue) y += self._hueSld.height # saturation slider self._satTxt = avg.WordsNode(text='saturation: %d' % self._fx.saturation, fontsize=12, pos=(0, y), parent=self) y += self._satTxt.height self._satSld = widget.Slider(range=(-100, 100), thumbPos=self._fx.saturation, width=self.width, pos=(0, y), parent=self) self._satSld.subscribe(widget.Slider.THUMB_POS_CHANGED, self._onSliderSat) y += self._satSld.height # lightness slider self._lightTxt = avg.WordsNode(text='lightness: %d' % self._fx.lightness, fontsize=12, pos=(0, y), parent=self) y += self._lightTxt.height self._lightSld = widget.Slider(range=(-100, 100), thumbPos=self._fx.lightness, width=self.width, pos=(0, y), parent=self) self._lightSld.subscribe(widget.Slider.THUMB_POS_CHANGED, self._onSliderLight) y += self._lightSld.height # colorize check box widget.Skin.default.defaultCheckBoxCfg['font'].color = 'FFFFFF' self._colCbox = widget.CheckBox(text='colorize', checked=self._fx.colorize, pos=(0, y), parent=self) self._colCbox.subscribe(widget.CheckBox.TOGGLED, self._onCheckBoxCol)