Exemplo n.º 1
0
    def testCheckBox(self):

        root = self.loadEmptyScene()
        avg.RectNode(size=(160, 120),
                     fillcolor="FFFFFF",
                     fillopacity=1,
                     parent=root)
        checkBox = widget.CheckBox(text="checkboxtext",
                                   pos=(10, 10),
                                   parent=root)

        self.start(
            True,
            (
                lambda: self.compareImage("testUICheckBoxUnchecked_Up"),
                lambda: self._sendMouseEvent(avg.Event.CURSOR_DOWN, 15, 15),
                lambda: self.compareImage("testUICheckBoxUnchecked_Down"),
                lambda: self._sendMouseEvent(avg.Event.CURSOR_UP, 15, 15),
                lambda: self.compareImage("testUICheckBoxChecked_Up"),
                lambda: self._sendMouseEvent(avg.Event.CURSOR_DOWN, 15, 15),
                lambda: self.compareImage("testUICheckBoxChecked_Down"),
                lambda: self._sendMouseEvent(avg.Event.CURSOR_UP, 15, 15),
                lambda: self.compareImage("testUICheckBoxUnchecked_Up"),
                lambda: checkBox.setEnabled(False),
                lambda: self.compareImage("testUICheckBoxUnchecked_Disabled"),
                lambda: checkBox.setEnabled(True),
                lambda: self.compareImage("testUICheckBoxUnchecked_Up"),
                # Test click on text.
                lambda: self._sendMouseEvent(avg.Event.CURSOR_DOWN, 50, 15),
                lambda: self.compareImage("testUICheckBoxUnchecked_Down"),
            ))
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
    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)