Esempio n. 1
0
 def test_textOnClick(self):
     text = Label(Page(App()), "hello")
     text.onClick(lambda: 1, add=False)
     self.assertEqual([1], text.click())
     text.onClick(lambda: 2, add=False)
     self.assertEqual([2], text.click())
     text.onClick(lambda: 3, add=True)
     self.assertEqual([2, 3], text.click())
     text.onClick(lambda: 4)
     self.assertEqual([2, 3, 4], text.click())
     text.onClick(lambda: 5, add=False)
     self.assertEqual([5], text.click())
Esempio n. 2
0
    def test_init(self):
        page = Page(App())
        label = Label(page, "Text")

        bind = label.createBind("<Button-1>", lambda: 5)
        self.assertEqual([5], label.callBind("<Button-1>"))

        bind.remove()
        self.assertEqual([], label.callBind("<Button-1>"))

        label.createBind("<Button-1>", lambda: 5)
        page.createBind("<Button-1>", lambda: 2)
        self.assertEqual([5, 2], label.callBind("<Button-1>"))

        label.setBindPropagation("<Button-1>", False)
        self.assertEqual([5], label.callBind("<Button-1>"))

        label.setBindPropagation("<Button-1>", True)
        self.assertEqual([5, 2], label.callBind("<Button-1>"))

        label.setBindPropagation("<Button-1>", False)
        label.createBind("<Button-1>", lambda: 5)
        label.createBind("<Button-1>", lambda: 2)
        self.assertEqual([5, 5, 2], label.callBind("<Button-1>"))

        label.createBind("<Button-1>", lambda: 3, add=False)
        self.assertEqual([3], label.callBind("<Button-1>"))

        label.createBind("<Button-1>", lambda: 5, name="hello")
        self.assertEqual([3, 5], label.callBind("<Button-1>"))

        label.createBind("<Button-1>", lambda: 5, name="hello")
        self.assertEqual([3, 5], label.callBind("<Button-1>"))

        label.createBind("<Button-1>", lambda: 5, name="hello", add=False)
        self.assertEqual([5], label.callBind("<Button-1>"))

        label.onClick(lambda: 5, add=False)
        label.onClick(lambda: 2)
        self.assertEqual([5, 2], label.click(animate=False))
        self.assertEqual([5, 2], label.click(animate=True))

        label.onRightClick(lambda: 5, add=False)
        label.onRightClick(lambda: 2)
        self.assertEqual([5, 2], label.rightClick(animate=False))
        self.assertEqual([5, 2], label.rightClick(animate=True))

        label.remove()
        self.assertEqual([], label.callBind("<Button-1>"))