コード例 #1
0
    def test_invalid_grid_layout(self):
        """ Test an invalid grid layout.

        """
        self.assertRaises(TypeError, setattr,
                          self.container.layout_constraints,
                          [grid([self.c1, spacer])])
コード例 #2
0
    def test_grid_layout(self):
        """ Test the grid layout helper.

        """
        from enable.layout.api import align, grid
        from enable.layout.layout_helpers import DefaultSpacing

        c3 = Component()
        c4 = Component()

        self.container.add(c3)
        self.container.add(c4)

        self.container.layout_constraints = [
            grid([self.c1, self.c2], [c3, c4]),
            align("layout_width", self.c1, self.c2, c3, c4),
            align("layout_height", self.c1, self.c2, c3, c4),
        ]

        space = DefaultSpacing.ABUTMENT
        c2_pos = [
            self.c1.position[0] + self.c1.bounds[0] + space,
            self.c1.position[1],
        ]
        self.assertTrue(self.c2.position == c2_pos)
コード例 #3
0
    def test_invalid_grid_layout(self):
        """ Test an invalid grid layout.

        """
        from enable.layout.api import spacer, grid

        self.assertRaises(TypeError, setattr,
                          self.container.layout_constraints,
                          [grid([self.c1, spacer])])
コード例 #4
0
    def test_grid_layout(self):
        """ Test the grid layout helper.

        """
        c3 = Component()
        c4 = Component()

        self.container.add(c3)
        self.container.add(c4)

        self.container.layout_constraints = [
            grid([self.c1, self.c2], [c3, c4]),
            align('layout_width', self.c1, self.c2, c3, c4),
            align('layout_height', self.c1, self.c2, c3, c4)
        ]

        space = DefaultSpacing.ABUTMENT
        c2_pos = [self.c1.position[0] + self.c1.bounds[0] + space,
                  self.c1.position[1]]
        self.assert_(self.c2.position == c2_pos)