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