Esempio n. 1
0
    def test_non_resizable(self):
        cont = GridContainer(shape=(2, 2),
                             spacing=(10, 10),
                             halign="center",
                             valign="center")
        ul = StaticPlotComponent([100, 100], resizable="")
        ur = StaticPlotComponent([100, 100], resizable="")
        ll = StaticPlotComponent([100, 100], resizable="")
        lr = StaticPlotComponent([100, 100], resizable="")
        cont.component_grid = [[ul, ur], [ll, lr]]

        cont.bounds = [240, 240]
        cont.do_layout()
        self.assert_tuple(ul.position, (10, 130))
        self.assert_tuple(ul.bounds, (100, 100))
        self.assert_tuple(ur.position, (130, 130))
        self.assert_tuple(ur.bounds, (100, 100))
        self.assert_tuple(ll.position, (10, 10))
        self.assert_tuple(ll.bounds, (100, 100))
        self.assert_tuple(lr.position, (130, 10))
        self.assert_tuple(lr.bounds, (100, 100))

        cont.bounds = [280, 280]
        cont.do_layout()
        self.assert_tuple(ul.position, (20, 160))
        self.assert_tuple(ul.bounds, (100, 100))
        self.assert_tuple(ur.position, (160, 160))
        self.assert_tuple(ur.bounds, (100, 100))
        self.assert_tuple(ll.position, (20, 20))
        self.assert_tuple(ll.bounds, (100, 100))
        self.assert_tuple(lr.position, (160, 20))
        self.assert_tuple(lr.bounds, (100, 100))
Esempio n. 2
0
    def test_non_resizable(self):
        cont = GridContainer(shape=(2,2), spacing=(10,10),
                             halign="center", valign="center")
        ul = StaticPlotComponent([100,100], resizable="")
        ur = StaticPlotComponent([100,100], resizable="")
        ll = StaticPlotComponent([100,100], resizable="")
        lr = StaticPlotComponent([100,100], resizable="")
        cont.component_grid = [[ul, ur], [ll, lr]]

        cont.bounds = [240, 240]
        cont.do_layout()
        self.assert_tuple(ul.position, (10,130))
        self.assert_tuple(ul.bounds, (100,100))
        self.assert_tuple(ur.position, (130,130))
        self.assert_tuple(ur.bounds, (100, 100))
        self.assert_tuple(ll.position, (10,10))
        self.assert_tuple(ll.bounds, (100,100))
        self.assert_tuple(lr.position, (130,10))
        self.assert_tuple(lr.bounds, (100,100))

        cont.bounds = [280, 280]
        cont.do_layout()
        self.assert_tuple(ul.position, (20,160))
        self.assert_tuple(ul.bounds, (100,100))
        self.assert_tuple(ur.position, (160,160))
        self.assert_tuple(ur.bounds, (100, 100))
        self.assert_tuple(ll.position, (20,20))
        self.assert_tuple(ll.bounds, (100,100))
        self.assert_tuple(lr.position, (160,20))
        self.assert_tuple(lr.bounds, (100,100))
Esempio n. 3
0
 def test_all_empty_cells(self):
     cont = GridContainer(shape=(2,2), spacing=(0,0))
     cont.component_grid = [[None, None], [None, None]]
     size = cont.get_preferred_size()
     self.assert_tuple(size, (0,0))
     cont.bounds = (100,100)
     cont.do_layout()
     return
Esempio n. 4
0
 def test_all_empty_cells(self):
     cont = GridContainer(shape=(2, 2), spacing=(0, 0))
     cont.component_grid = [[None, None], [None, None]]
     size = cont.get_preferred_size()
     self.assert_tuple(size, (0, 0))
     cont.bounds = (100, 100)
     cont.do_layout()
     return
Esempio n. 5
0
 def test_some_empty_cells(self):
     cont = GridContainer(shape=(2,2), spacing=(0,0))
     a = StaticPlotComponent([100,30])
     b = StaticPlotComponent([50,40])
     cont.component_grid = [[a, None], [None, b]]
     size = cont.get_preferred_size()
     self.assert_tuple(size, (150, 70))
     cont.bounds = size
     cont.do_layout()
     self.assert_tuple(a.outer_position, (0, 40))
     self.assert_tuple(a.outer_bounds, (100, 30))
     self.assert_tuple(b.outer_position, (100,0))
     self.assert_tuple(b.outer_bounds, (50, 40))
Esempio n. 6
0
 def test_some_empty_cells(self):
     cont = GridContainer(shape=(2, 2), spacing=(0, 0))
     a = StaticPlotComponent([100, 30])
     b = StaticPlotComponent([50, 40])
     cont.component_grid = [[a, None], [None, b]]
     size = cont.get_preferred_size()
     self.assert_tuple(size, (150, 70))
     cont.bounds = size
     cont.do_layout()
     self.assert_tuple(a.outer_position, (0, 40))
     self.assert_tuple(a.outer_bounds, (100, 30))
     self.assert_tuple(b.outer_position, (100, 0))
     self.assert_tuple(b.outer_bounds, (50, 40))
Esempio n. 7
0
    def test_resizable_mixed_h(self):
        # Tests the layout of a non-resizable component, a resizable with a
        # preferred size, and a fully resizable component in a horizontal
        # GridContainer
        cont = GridContainer(shape=(3,1), spacing=(0,0),
                             halign="center", valign="center")
        left = StaticPlotComponent([50,10], resizable="")
        middle = ResizablePlotComponent([100,10])
        right = StaticPlotComponent([0,0], resizable="hv")

        cont.component_grid = [[left, middle, right]]
        cont.bounds = [200, 10]
        cont.do_layout()
        self.assert_tuple(left.position, (0,0))
        self.assert_tuple(left.bounds, (50,10))
        self.assert_tuple(middle.position, (50,0))
        self.assert_tuple(middle.bounds, (100,10))
        self.assert_tuple(right.position, (150,0))
        self.assert_tuple(right.bounds, (50,10))
Esempio n. 8
0
 def test_resizable2(self):
     # Tests a resizable component that also has a preferred size
     cont = GridContainer(shape=(2,2), spacing=(0,0),
                          halign="center", valign="center")
     ul = StaticPlotComponent([150,150], resizable="hv")
     lr = StaticPlotComponent([0,0], resizable="hv")
     top = StaticPlotComponent([0,0], resizable="hv")
     left = StaticPlotComponent([0,0], resizable="hv")
     cont.component_grid = [[ul, top], [left, lr]]
     cont.bounds = [200, 200]
     cont.do_layout()
     self.assert_tuple(ul.position, (0,100))
     self.assert_tuple(ul.bounds, (100,100))
     self.assert_tuple(top.position, (100,100))
     self.assert_tuple(top.bounds, (100,100))
     self.assert_tuple(left.position, (0,0))
     self.assert_tuple(left.bounds, (100,100))
     self.assert_tuple(lr.position, (100,0))
     self.assert_tuple(lr.bounds, (100,100))
Esempio n. 9
0
 def test_spacing(self):
     cont = GridContainer(shape=(2,2), spacing=(10,10),
                          halign="center", valign="center")
     ul = StaticPlotComponent([50,50])     # upper-left component
     lr = StaticPlotComponent([100,100])   # lower-right component
     top = StaticPlotComponent([0,0], resizable="hv")
     left = StaticPlotComponent([0,0], resizable="hv")
     cont.component_grid = [[ul, top], [left, lr]]
     cont.bounds = [190, 190]
     cont.do_layout()
     self.assert_tuple(ul.position, (10,130))
     self.assert_tuple(ul.bounds, (50,50))
     self.assert_tuple(top.position, (80,130))
     self.assert_tuple(top.bounds, (100, 50))
     self.assert_tuple(left.position, (10,10))
     self.assert_tuple(left.bounds, (50,100))
     self.assert_tuple(lr.position, (80,10))
     self.assert_tuple(lr.bounds, (100,100))
     return
Esempio n. 10
0
 def test_two_by_two(self):
     """ Tests a 2x2 grid of components """
     cont = GridContainer(shape=(2,2), halign="center", valign="center")
     ul = StaticPlotComponent([50,50])     # upper-left component
     lr = StaticPlotComponent([100,100])   # lower-right component
     top = StaticPlotComponent([0,0], resizable="hv")
     left = StaticPlotComponent([0,0], resizable="hv")
     cont.component_grid = [[ul, top], [left, lr]]
     cont.bounds = [150, 150]
     cont.do_layout()
     self.assert_tuple(ul.position, (0,100))
     self.assert_tuple(ul.bounds, (50,50))
     self.assert_tuple(top.position, (50,100))
     self.assert_tuple(top.bounds, (100, 50))
     self.assert_tuple(left.position, (0,0))
     self.assert_tuple(left.bounds, (50,100))
     self.assert_tuple(lr.position, (50,0))
     self.assert_tuple(lr.bounds, (100,100))
     return
Esempio n. 11
0
 def test_two_by_two(self):
     """ Tests a 2x2 grid of components """
     cont = GridContainer(shape=(2, 2), halign="center", valign="center")
     ul = StaticPlotComponent([50, 50])  # upper-left component
     lr = StaticPlotComponent([100, 100])  # lower-right component
     top = StaticPlotComponent([0, 0], resizable="hv")
     left = StaticPlotComponent([0, 0], resizable="hv")
     cont.component_grid = [[ul, top], [left, lr]]
     cont.bounds = [150, 150]
     cont.do_layout()
     self.assert_tuple(ul.position, (0, 100))
     self.assert_tuple(ul.bounds, (50, 50))
     self.assert_tuple(top.position, (50, 100))
     self.assert_tuple(top.bounds, (100, 50))
     self.assert_tuple(left.position, (0, 0))
     self.assert_tuple(left.bounds, (50, 100))
     self.assert_tuple(lr.position, (50, 0))
     self.assert_tuple(lr.bounds, (100, 100))
     return
Esempio n. 12
0
 def test_resizable_mixed2(self):
     # Tests laying out resizable components with preferred
     # sized alongside non-resizable components.
     cont = GridContainer(shape=(2,2), spacing=(0,0),
                          halign="center", valign="center")
     ul = ResizablePlotComponent([150,150])
     lr = StaticPlotComponent([50,50], resizable="")
     top = StaticPlotComponent([0,0], resizable="hv")
     left = StaticPlotComponent([0,0], resizable="hv")
     cont.component_grid = [[ul, top], [left, lr]]
     cont.bounds = [200, 200]
     cont.do_layout()
     self.assert_tuple(ul.position, (0,50))
     self.assert_tuple(ul.bounds, (150,150))
     self.assert_tuple(top.position, (150,50))
     self.assert_tuple(top.bounds, (50,150))
     self.assert_tuple(left.position, (0,0))
     self.assert_tuple(left.bounds, (150,50))
     self.assert_tuple(lr.position, (150,0))
     self.assert_tuple(lr.bounds, (50,50))
Esempio n. 13
0
 def test_resizable_mixed(self):
     """ Tests mixing resizable and non-resizable components """
     cont = GridContainer(shape=(2,2), spacing=(10,10),
                          halign="center", valign="center")
     ul = StaticPlotComponent([0,0], resizable="hv")
     lr = StaticPlotComponent([0,0], resizable="hv")
     top = StaticPlotComponent([0,0], resizable="hv")
     left = StaticPlotComponent([100,100], resizable="")
     cont.component_grid = [[ul, top], [left, lr]]
     cont.bounds = [240, 240]
     cont.do_layout()
     self.assert_tuple(ul.position, (10,130))
     self.assert_tuple(ul.bounds, (100,100))
     self.assert_tuple(top.position, (130,130))
     self.assert_tuple(top.bounds, (100, 100))
     self.assert_tuple(left.position, (10,10))
     self.assert_tuple(left.bounds, (100,100))
     self.assert_tuple(lr.position, (130,10))
     self.assert_tuple(lr.bounds, (100,100))
     return
Esempio n. 14
0
    def test_resizable_mixed_h(self):
        # Tests the layout of a non-resizable component, a resizable with a
        # preferred size, and a fully resizable component in a horizontal
        # GridContainer
        cont = GridContainer(shape=(3, 1),
                             spacing=(0, 0),
                             halign="center",
                             valign="center")
        left = StaticPlotComponent([50, 10], resizable="")
        middle = ResizablePlotComponent([100, 10])
        right = StaticPlotComponent([0, 0], resizable="hv")

        cont.component_grid = [[left, middle, right]]
        cont.bounds = [200, 10]
        cont.do_layout()
        self.assert_tuple(left.position, (0, 0))
        self.assert_tuple(left.bounds, (50, 10))
        self.assert_tuple(middle.position, (50, 0))
        self.assert_tuple(middle.bounds, (100, 10))
        self.assert_tuple(right.position, (150, 0))
        self.assert_tuple(right.bounds, (50, 10))
Esempio n. 15
0
 def test_resizable2(self):
     # Tests a resizable component that also has a preferred size
     cont = GridContainer(shape=(2, 2),
                          spacing=(0, 0),
                          halign="center",
                          valign="center")
     ul = StaticPlotComponent([150, 150], resizable="hv")
     lr = StaticPlotComponent([0, 0], resizable="hv")
     top = StaticPlotComponent([0, 0], resizable="hv")
     left = StaticPlotComponent([0, 0], resizable="hv")
     cont.component_grid = [[ul, top], [left, lr]]
     cont.bounds = [200, 200]
     cont.do_layout()
     self.assert_tuple(ul.position, (0, 100))
     self.assert_tuple(ul.bounds, (100, 100))
     self.assert_tuple(top.position, (100, 100))
     self.assert_tuple(top.bounds, (100, 100))
     self.assert_tuple(left.position, (0, 0))
     self.assert_tuple(left.bounds, (100, 100))
     self.assert_tuple(lr.position, (100, 0))
     self.assert_tuple(lr.bounds, (100, 100))
Esempio n. 16
0
 def test_spacing(self):
     cont = GridContainer(shape=(2, 2),
                          spacing=(10, 10),
                          halign="center",
                          valign="center")
     ul = StaticPlotComponent([50, 50])  # upper-left component
     lr = StaticPlotComponent([100, 100])  # lower-right component
     top = StaticPlotComponent([0, 0], resizable="hv")
     left = StaticPlotComponent([0, 0], resizable="hv")
     cont.component_grid = [[ul, top], [left, lr]]
     cont.bounds = [190, 190]
     cont.do_layout()
     self.assert_tuple(ul.position, (10, 130))
     self.assert_tuple(ul.bounds, (50, 50))
     self.assert_tuple(top.position, (80, 130))
     self.assert_tuple(top.bounds, (100, 50))
     self.assert_tuple(left.position, (10, 10))
     self.assert_tuple(left.bounds, (50, 100))
     self.assert_tuple(lr.position, (80, 10))
     self.assert_tuple(lr.bounds, (100, 100))
     return
Esempio n. 17
0
 def test_resizable_mixed2(self):
     # Tests laying out resizable components with preferred
     # sized alongside non-resizable components.
     cont = GridContainer(shape=(2, 2),
                          spacing=(0, 0),
                          halign="center",
                          valign="center")
     ul = ResizablePlotComponent([150, 150])
     lr = StaticPlotComponent([50, 50], resizable="")
     top = StaticPlotComponent([0, 0], resizable="hv")
     left = StaticPlotComponent([0, 0], resizable="hv")
     cont.component_grid = [[ul, top], [left, lr]]
     cont.bounds = [200, 200]
     cont.do_layout()
     self.assert_tuple(ul.position, (0, 50))
     self.assert_tuple(ul.bounds, (150, 150))
     self.assert_tuple(top.position, (150, 50))
     self.assert_tuple(top.bounds, (50, 150))
     self.assert_tuple(left.position, (0, 0))
     self.assert_tuple(left.bounds, (150, 50))
     self.assert_tuple(lr.position, (150, 0))
     self.assert_tuple(lr.bounds, (50, 50))
Esempio n. 18
0
 def test_resizable_mixed(self):
     """ Tests mixing resizable and non-resizable components """
     cont = GridContainer(shape=(2, 2),
                          spacing=(10, 10),
                          halign="center",
                          valign="center")
     ul = StaticPlotComponent([0, 0], resizable="hv")
     lr = StaticPlotComponent([0, 0], resizable="hv")
     top = StaticPlotComponent([0, 0], resizable="hv")
     left = StaticPlotComponent([100, 100], resizable="")
     cont.component_grid = [[ul, top], [left, lr]]
     cont.bounds = [240, 240]
     cont.do_layout()
     self.assert_tuple(ul.position, (10, 130))
     self.assert_tuple(ul.bounds, (100, 100))
     self.assert_tuple(top.position, (130, 130))
     self.assert_tuple(top.bounds, (100, 100))
     self.assert_tuple(left.position, (10, 10))
     self.assert_tuple(left.bounds, (100, 100))
     self.assert_tuple(lr.position, (130, 10))
     self.assert_tuple(lr.bounds, (100, 100))
     return