示例#1
0
    def test_redistribute_weight_resize(self):
        dockpaned = DockPaned()
        dockgroup1 = DockGroup()
        dockgroup2 = DockGroup()

        dockpaned.insert_item(dockgroup1, weight=0.5)
        dockpaned._items[0].min_size = 20

        self.assertEquals(1, len(dockpaned._items))
        self.assertEquals(None, dockpaned._items[0].weight)
        self.assertEquals(0.5, dockpaned._items[0].weight_request)

        dockpaned._redistribute_weight(100)

        self.assertEquals(1.0, dockpaned._items[0].weight)
        self.assertEquals(None, dockpaned._items[0].weight_request)

        dockpaned.insert_item(dockgroup2, weight=0.5)
        dockpaned._items[1].min_size = 20

        self.assertTrue(0.5, dockpaned._items[1].weight_request)

        dockpaned._redistribute_weight(100)

        self.assertAlmostEquals(0.5, dockpaned._items[0].weight, 4)
        self.assertAlmostEquals(0.5, dockpaned._items[1].weight, 4)
示例#2
0
    def test_item_added_signal(self):
        add_events = []
        item_added_events = []

        def on_add(self, widget):
            add_events.append(widget)

        def on_item_added(dockpaned, child):
            item_added_events.append(child)

        dockgroup1 = DockGroup()
        dockgroup2 = DockGroup()
        dockpaned = DockPaned()
        dockpaned.connect('add', on_add)
        dockpaned.connect('item-added', on_item_added)
        dockpaned.add(dockgroup1)
        dockpaned.insert_item(dockgroup2)

        self.assertTrue(dockgroup1 in item_added_events)
        self.assertTrue(dockgroup1 in add_events)
        self.assertTrue(dockgroup2 in item_added_events)
        self.assertFalse(dockgroup2 in add_events)

        dockgroup2.destroy()
        dockgroup1.destroy()
        dockpaned.destroy()
示例#3
0
    def test_insert_item(self):
        dockgroup1 = DockGroup()
        dockgroup2 = DockGroup()
        dockgroup3 = DockGroup()
        dockpaned = DockPaned()
        item_num1 = dockpaned.insert_item(dockgroup1, position=None)
        self.assertTrue(item_num1 == 0)
        item_num2 = dockpaned.insert_item(dockgroup2, position=-1)
        self.assertTrue(item_num2 == 1)
        item_num3 = dockpaned.insert_item(dockgroup3, position=1, weight=0.5)
        self.assertTrue(item_num3 == 1)

        self.assertTrue(dockpaned.get_nth_item(0) is dockgroup1)
        self.assertTrue(dockpaned.get_nth_item(1) is dockgroup3)
        self.assertTrue(dockpaned.get_nth_item(2) is dockgroup2)

        dockgroup3.destroy()
        dockgroup2.destroy()
        dockgroup1.destroy()
        dockpaned.destroy()