Ejemplo n.º 1
0
 def test_halign(self):
     container = VPlotContainer(bounds=[200, 300], halign="center")
     comp1 = StaticPlotComponent([100, 200])
     container.add(comp1)
     container.do_layout()
     self.assertEqual(comp1.position, [50, 0])
     container.halign = "right"
     container.do_layout(force=True)
     self.assertEqual(comp1.position, [100, 0])
     return
Ejemplo n.º 2
0
 def test_halign(self):
     container = VPlotContainer(bounds=[200,300], halign="center")
     comp1 = StaticPlotComponent([100,200])
     container.add(comp1)
     container.do_layout()
     self.assertEqual(comp1.position, [50,0])
     container.halign="right"
     container.do_layout(force=True)
     self.assertEqual(comp1.position, [100,0])
     return
Ejemplo n.º 3
0
 def test_stack_nonresize(self):
     container = VPlotContainer(bounds=[100,300])
     comp1 = StaticPlotComponent([70,100])
     comp2 = StaticPlotComponent([80,90])
     comp3 = StaticPlotComponent([90,80])
     container.add(comp1, comp2, comp3)
     container.do_layout()
     self.assert_tuple(container.get_preferred_size(), (90, 270))
     self.assert_tuple(container.bounds, (100,300))
     self.assert_tuple(comp1.position, (0,0))
     self.assert_tuple(comp2.position, (0,100))
     self.assert_tuple(comp3.position, (0,190))
     return
Ejemplo n.º 4
0
 def test_stack_nonresize(self):
     container = VPlotContainer(bounds=[100, 300])
     comp1 = StaticPlotComponent([70, 100])
     comp2 = StaticPlotComponent([80, 90])
     comp3 = StaticPlotComponent([90, 80])
     container.add(comp1, comp2, comp3)
     container.do_layout()
     self.assert_tuple(container.get_preferred_size(), (90, 270))
     self.assert_tuple(container.bounds, (100, 300))
     self.assert_tuple(comp1.position, (0, 0))
     self.assert_tuple(comp2.position, (0, 100))
     self.assert_tuple(comp3.position, (0, 190))
     return
Ejemplo n.º 5
0
 def test_stack_one_resize(self):
     "Checks stacking with 1 resizable component thrown in"
     container = VPlotContainer(bounds=[100,300])
     comp1 = StaticPlotComponent([70,100])
     comp2 = StaticPlotComponent([80,90])
     comp3 = StaticPlotComponent([90,80], resizable='hv')
     comp4 = StaticPlotComponent([50,40])
     container.add(comp1, comp2, comp3, comp4)
     container.do_layout()
     self.assert_tuple(container.get_preferred_size(), (80,230))
     self.assert_tuple(container.bounds, (100,300))
     self.assert_tuple(comp1.position, (0,0))
     self.assert_tuple(comp2.position, (0,100))
     self.assert_tuple(comp3.position, (0,190))
     self.assert_tuple(comp4.position, (0,260))
     return
Ejemplo n.º 6
0
 def test_stack_one_resize(self):
     "Checks stacking with 1 resizable component thrown in"
     container = VPlotContainer(bounds=[100, 300])
     comp1 = StaticPlotComponent([70, 100])
     comp2 = StaticPlotComponent([80, 90])
     comp3 = StaticPlotComponent([90, 80], resizable='hv')
     comp4 = StaticPlotComponent([50, 40])
     container.add(comp1, comp2, comp3, comp4)
     container.do_layout()
     self.assert_tuple(container.get_preferred_size(), (80, 230))
     self.assert_tuple(container.bounds, (100, 300))
     self.assert_tuple(comp1.position, (0, 0))
     self.assert_tuple(comp2.position, (0, 100))
     self.assert_tuple(comp3.position, (0, 190))
     self.assert_tuple(comp4.position, (0, 260))
     return
Ejemplo n.º 7
0
    def test_fit_components(self):
        container = VPlotContainer(bounds=[200,300], resizable="v", fit_components="v")
        comp1 = StaticPlotComponent([50,100], padding=5)
        comp2 = StaticPlotComponent([50,120], padding=5)
        container.add(comp1)
        container.add(comp2)
        self.assert_tuple(container.get_preferred_size(), (200,240))
        # The container should not change its size as a result of its fit_components
        # being set.
        self.assert_tuple(container.bounds, (200,300))
        container.bounds = container.get_preferred_size()
        container.do_layout()

        container.padding = 8
        self.assert_tuple(container.get_preferred_size(), (216,256))
        container.do_layout()
        self.assert_tuple(comp1.outer_position, (0,0))
        self.assert_tuple(comp2.outer_position, (0,110))
Ejemplo n.º 8
0
    def test_fit_components(self):
        container = VPlotContainer(bounds=[200, 300],
                                   resizable="v",
                                   fit_components="v")
        comp1 = StaticPlotComponent([50, 100], padding=5)
        comp2 = StaticPlotComponent([50, 120], padding=5)
        container.add(comp1)
        container.add(comp2)
        self.assert_tuple(container.get_preferred_size(), (200, 240))
        # The container should not change its size as a result of its fit_components
        # being set.
        self.assert_tuple(container.bounds, (200, 300))
        container.bounds = container.get_preferred_size()
        container.do_layout()

        container.padding = 8
        self.assert_tuple(container.get_preferred_size(), (216, 256))
        container.do_layout()
        self.assert_tuple(comp1.outer_position, (0, 0))
        self.assert_tuple(comp2.outer_position, (0, 110))