本文整理汇总了Python中kivy.uix.stacklayout.StackLayout.spacing方法的典型用法代码示例。如果您正苦于以下问题:Python StackLayout.spacing方法的具体用法?Python StackLayout.spacing怎么用?Python StackLayout.spacing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.uix.stacklayout.StackLayout
的用法示例。
在下文中一共展示了StackLayout.spacing方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_stacklayout_spacing
# 需要导入模块: from kivy.uix.stacklayout import StackLayout [as 别名]
# 或者: from kivy.uix.stacklayout.StackLayout import spacing [as 别名]
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])
示例2: test_stacklayout_overflow
# 需要导入模块: from kivy.uix.stacklayout import StackLayout [as 别名]
# 或者: from kivy.uix.stacklayout.StackLayout import spacing [as 别名]
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)