Esempio n. 1
0
    def testTextButton(self):
        root = self.loadEmptyScene()
        button = widget.TextButton("text", parent=root, size=(50, 42))
        self.messageTester = MessageTester(button, [
            widget.Button.CLICKED, widget.Button.PRESSED,
            widget.Button.RELEASED
        ], self)
        self.start(
            True,
            (  # Standard down->up
                self._genMouseEventFrames(avg.Event.CURSOR_DOWN, 0, 0,
                                          [widget.Button.PRESSED]),
                lambda: self.compareImage("testTextButtonDown"),
                self._genMouseEventFrames(
                    avg.Event.CURSOR_UP, 0, 0,
                    [widget.Button.CLICKED, widget.Button.RELEASED]),
                lambda: self.compareImage("testTextButtonUp"),

                # Check disabled graphics
                lambda: self.assert_(button.enabled),
                lambda: button.setEnabled(False),
                lambda: self.assert_(not (button.enabled)),
                lambda: self.compareImage("testTextButtonDisabled"),
                lambda: button.setEnabled(True),

                # Change text
                lambda: button.setText("newText"),
                lambda: self.compareImage("testTextButtonUpNewText"),
                self._genMouseEventFrames(avg.Event.CURSOR_DOWN, 0, 0,
                                          [widget.Button.PRESSED]),
                lambda: self.compareImage("testTextButtonDownNewText"),
            ))
Esempio n. 2
0
    def onInit(self):
        # avg.VideoWriter requires a canvas as source
        # (can be the main canvas returned by player.getMainCanvas())
        canvas = player.createCanvas(id='source_canvas', size=self.size)
        root = canvas.getRootNode()

        # some nodes in source canvas
        self._text = avg.WordsNode(parent=root, text='000000', fontsize=42)
        self._text.pos = (self.size - self._text.size) / 2
        self._rect = avg.RectNode(parent=root, size=(200, 200))
        self._rect.pos = (self.size - self._rect.size) / 2

        # show source canvas on screen (not required for video recording)
        avg.ImageNode(parent=self, href='canvas:source_canvas')

        # start writing source canvas to video file
        fps = int(player.getFramerate())
        self._video_writer = avg.VideoWriter(canvas, 'video_writer.avi', fps)
        self._writing = True

        # these nodes are not included in the video (outside source canvas)
        avg.WordsNode(parent=self,
                      text='writing to "%s"' % self._video_writer.filename)
        self._btn = widget.TextButton(parent=self,
                                      pos=(0, 20),
                                      size=(100, 25),
                                      text='PAUSE')
        self._btn.subscribe(widget.Button.CLICKED, self._onButton)
Esempio n. 3
0
 def onInit(self):
     self.textNode = avg.WordsNode(pos=(10, 10), text="", parent=self)
     for i in range(0, 10):
         pos = avg.Point2D(10, 40) + ((i % 3) * 40, (i // 3) * 40)
         node = widget.TextButton(pos=pos,
                                  size=(30, 30),
                                  text=str(i),
                                  parent=self)
         node.subscribe(widget.Button.CLICKED, lambda i=i: self.onDown(i))
Esempio n. 4
0
    def __createGUI(self):
        self.__guiDiv = avg.DivNode(pos=(self.__optWidth + 10, 10),
                                    parent=self)

        self.__colorWords = avg.WordsNode(pos=(0, 14), parent=self.__guiDiv)
        self.__colorWords.text = "Key Color: " + self.__filter.color
        self.__colorRect = avg.RectNode(pos=(200, 12),
                                        size=(20, 20),
                                        fillcolor=self.__filter.color,
                                        fillopacity=1,
                                        color="FFFFFF",
                                        parent=self.__guiDiv)
        self.__camNode.subscribe(avg.Node.CURSOR_DOWN, self.__onColorDown)

        FXSlider(1,
                 0.0,
                 1.0,
                 self.__filter,
                 "htolerance",
                 "Hue Tolerance",
                 False,
                 parent=self.__guiDiv)
        FXSlider(2,
                 0.0,
                 1.0,
                 self.__filter,
                 "stolerance",
                 "Saturation Tolerance",
                 False,
                 parent=self.__guiDiv)
        FXSlider(3,
                 0.0,
                 1.0,
                 self.__filter,
                 "ltolerance",
                 "Lightness Tolerance",
                 False,
                 parent=self.__guiDiv)
        FXSlider(4,
                 0.0,
                 1.0,
                 self.__filter,
                 "softness",
                 "Softness",
                 False,
                 parent=self.__guiDiv)
        FXSlider(5,
                 0,
                 8,
                 self.__filter,
                 "erosion",
                 "Erosion",
                 True,
                 parent=self.__guiDiv)
        FXSlider(6,
                 0.0,
                 1.0,
                 self.__filter,
                 "spillthreshold",
                 "Spill Suppression",
                 False,
                 parent=self.__guiDiv)

        button = widget.TextButton(pos=(0, 332),
                                   text="Whitebalance",
                                   size=(100, 22),
                                   parent=self.__guiDiv)
        button.subscribe(button.CLICKED, self.__onWhitebalance)
        button = widget.TextButton(pos=(110, 332),
                                   text="Dump Config",
                                   size=(100, 22),
                                   parent=self.__guiDiv)
        button.subscribe(button.CLICKED, self.__dumpConfig)

        FXSlider(9,
                 0,
                 500,
                 self.__camNode,
                 "shutter",
                 "Shutter",
                 True,
                 parent=self.__guiDiv)
        FXSlider(10,
                 128,
                 1023,
                 self.__camNode,
                 "gain",
                 "Gain",
                 True,
                 parent=self.__guiDiv)