예제 #1
0
 def test_stacklayout_nospace(self):
     # happens when padding is too big
     sl = StackLayout()
     wgts = [Widget(size_hint=(1., .25)) for i in range(1, 4)]
     for wgt in wgts:
         sl.add_widget(wgt)
     sl.padding = 10
     sl.do_layout()
예제 #2
0
 def test_stacklayout_nospace(self):
     # happens when padding is too big
     sl = StackLayout()
     wgts = [Widget(size_hint=(1., .25)) for i in range(1, 4)]
     for wgt in wgts:
         sl.add_widget(wgt)
     sl.padding = 10
     sl.do_layout()
    def test_tb_lr_stacklayout(self):
        stacklayout = StackLayout(orientation='tb-lr',
                                  size=(200, 200),
                                  padding=20,
                                  spacing=10)

        widget = Widget(width=100, size_hint=(0.2, 0.4))
        stacklayout.add_widget(widget)
        stacklayout.do_layout()

        self.assertEqual(stacklayout.top - widget.top, 20)
예제 #4
0
    def test_stacklayout_spacing(self):
        sl = StackLayout()
        wgts = [Widget(size_hint=(.5, .5)) for i in range(4)]
        for wgt in wgts:
            sl.add_widget(wgt)
        sl.spacing = 10
        sl.do_layout()

        self.assertEqual(wgts[0].pos, [0, sl.height / 2.])
        self.assertEqual(wgts[1].pos, [sl.width / 2. + 5, sl.height / 2.])
        self.assertEqual(wgts[2].pos, [0, -10])
        self.assertEqual(wgts[3].pos, [sl.width / 2. + 5, -10])
예제 #5
0
    def test_stacklayout_padding(self):
        sl = StackLayout()
        wgts = [Widget(size_hint=(.5, .5)) for i in range(4)]
        for wgt in wgts:
            sl.add_widget(wgt)
        sl.padding = 5.
        sl.do_layout()

        self.assertEqual(wgts[0].pos, [5., sl.height / 2.])
        self.assertEqual(wgts[1].pos, [sl.width / 2., sl.height / 2.])
        self.assertEqual(wgts[2].pos, [5., 5.])
        self.assertEqual(wgts[3].pos, [sl.width / 2., 5.])
예제 #6
0
    def test_stacklayout_default(self):
        # Default orientation is lr-tb.
        sl = StackLayout()
        wgts = [Widget(size_hint=(.5, .5)) for i in range(4)]
        for wgt in wgts:
            sl.add_widget(wgt)
        sl.do_layout()

        self.assertEqual(wgts[0].pos, [0, sl.height / 2.])
        self.assertEqual(wgts[1].pos, [sl.width / 2., sl.height / 2.])
        self.assertEqual(wgts[2].pos, [0, 0])
        self.assertEqual(wgts[3].pos, [sl.width / 2., 0])
예제 #7
0
    def test_tb_lr_stacklayout(self):
        stacklayout = StackLayout(
            orientation='tb-lr',
            size=(200, 200),
            padding=20,
            spacing=10)

        widget = Widget(width=100, size_hint=(0.2, 0.4))
        stacklayout.add_widget(widget)
        stacklayout.do_layout()

        self.assertEqual(stacklayout.top - widget.top, 20)
예제 #8
0
    def test_stacklayout_spacing(self):
        sl = StackLayout()
        wgts = [Widget(size_hint=(.5, .5)) for i in range(4)]
        for wgt in wgts:
            sl.add_widget(wgt)
        sl.spacing = 10
        sl.do_layout()

        self.assertEqual(wgts[0].pos, [0, sl.height / 2.])
        self.assertEqual(wgts[1].pos, [sl.width / 2. + 5, sl.height / 2.])
        self.assertEqual(wgts[2].pos, [0, -10])
        self.assertEqual(wgts[3].pos, [sl.width / 2. + 5, -10])
예제 #9
0
    def test_stacklayout_padding(self):
        sl = StackLayout()
        wgts = [Widget(size_hint=(.5, .5)) for i in range(4)]
        for wgt in wgts:
            sl.add_widget(wgt)
        sl.padding = 5.
        sl.do_layout()

        self.assertEqual(wgts[0].pos, [5., sl.height / 2.])
        self.assertEqual(wgts[1].pos, [sl.width / 2., sl.height / 2.])
        self.assertEqual(wgts[2].pos, [5., 5.])
        self.assertEqual(wgts[3].pos, [sl.width / 2., 5.])
예제 #10
0
    def test_stacklayout_fixed_size(self):
        sl = StackLayout()
        wgts = [Widget(size=(50, 50), size_hint=(None, None))
                for i in range(4)]
        for wgt in wgts:
            sl.add_widget(wgt)
        sl.do_layout()

        self.assertEqual(wgts[0].pos, [0, sl.height / 2.])
        self.assertEqual(wgts[1].pos, [sl.width / 2., sl.height / 2.])
        self.assertEqual(wgts[2].pos, [0, 0])
        self.assertEqual(wgts[3].pos, [sl.width / 2., 0])
예제 #11
0
    def test_stacklayout_default(self):
        # Default orientation is lr-tb.
        sl = StackLayout()
        wgts = [Widget(size_hint=(.5, .5)) for i in range(4)]
        for wgt in wgts:
            sl.add_widget(wgt)
        sl.do_layout()

        self.assertEqual(wgts[0].pos, [0, sl.height / 2.])
        self.assertEqual(wgts[1].pos, [sl.width / 2., sl.height / 2.])
        self.assertEqual(wgts[2].pos, [0, 0])
        self.assertEqual(wgts[3].pos, [sl.width / 2., 0])
예제 #12
0
    def test_stacklayout_fixed_size(self):
        sl = StackLayout()
        wgts = [
            Widget(size=(50, 50), size_hint=(None, None)) for i in range(4)
        ]
        for wgt in wgts:
            sl.add_widget(wgt)
        sl.do_layout()

        self.assertEqual(wgts[0].pos, [0, sl.height / 2.])
        self.assertEqual(wgts[1].pos, [sl.width / 2., sl.height / 2.])
        self.assertEqual(wgts[2].pos, [0, 0])
        self.assertEqual(wgts[3].pos, [sl.width / 2., 0])
예제 #13
0
    def test_stacklayout_overflow(self):
        sl = StackLayout()
        wgts = [Widget(size_hint=(.2 * i, .2 * i)) for i in range(1, 4)]
        for wgt in wgts:
            sl.add_widget(wgt)
        sl.padding = 5
        sl.spacing = 5
        sl.do_layout()

        self.assertEqual(wgts[0].pos, [5, 77])
        self.assertEqual(wgts[1].pos, [27, 59])
        # floating point error, requires almost equal
        self.assertAlmostEqual(wgts[2].pos[0], 5)
        self.assertAlmostEqual(wgts[2].pos[1], 0)
예제 #14
0
    def test_stacklayout_overflow(self):
        sl = StackLayout()
        wgts = [Widget(size_hint=(.2 * i, .2 * i)) for i in range(1, 4)]
        for wgt in wgts:
            sl.add_widget(wgt)
        sl.padding = 5
        sl.spacing = 5
        sl.do_layout()

        self.assertEqual(wgts[0].pos, [5, 77])
        self.assertEqual(wgts[1].pos, [27, 59])
        # floating point error, requires almost equal
        self.assertAlmostEqual(wgts[2].pos[0], 5)
        self.assertAlmostEqual(wgts[2].pos[1], 0)
예제 #15
0
 def test_stacklayout_no_children(self):
     sl = StackLayout()
     sl.do_layout()
예제 #16
0
 def test_stacklayout_no_children(self):
     sl = StackLayout()
     sl.do_layout()