Esempio n. 1
0
    def test_anchors_dock(self):
        view1 = View()
        view2 = View()
        view3 = View()
        view4 = View()
        view5 = View()

        view1.dock = view2.top_left
        assert view1.parent == view2
        assert self.constraints(view1) == 'top=id2.top;left=id2.left'

        view4.dock = view1.top
        view4.height = 100
        assert self.constraints(view4) == 'top=id1.top;left=id1.left;right=id1.right;height=100'

        view2.dock = view3.top + 16
        assert self.constraints(view2) == 'top=id3.top+16;left=id3.left+16;right=id3.right-16'

        view4.parent = view1
        view3.dock = view4.below
        assert view3.parent == view1
        assert self.constraints(view3) == 'top=id4.bottom;centerX=id4.centerX;width=id4.width'

        view5.dock = view4.above + 4
        assert self.constraints(view5) == 'bottom=id4.top-4;centerX=id4.centerX;width=id4.width'
Esempio n. 2
0
    def test_anchors_docking_center(self):
        view1 = View()
        view2 = View()

        view2.dock = view1.center
        assert view2.parent == view1
        assert self.constraints(view2) == 'centerX=id1.centerX;centerY=id1.centerY'