0
如何在不同的窗口小部件中使用房产? 我有这样的代码:从基维的其他窗口获取房产
的Python文件
class Control(ToggleButton):
width_multiplier = NumericProperty(1)
class MainScreen(StackLayout):
pass
class HomeControl(App):
def build(self):
return MainScreen()
if __name__ == '__main__':
HomeControl().run()
KV文件
<Control>:
size_hint: None,None
height: '100dp'
width: self.width_multiplier * self.height + (self.width_multiplier - 1) * spacing
halign: 'center'
<MainScreen>:
orientation: 'lr-tb'
spacing: '10dp'
padding: '15dp'
Control:
text: 'Button'
Control:
text: 'Long Button'
width_multiplier: 2
的Control
窗口小部件的宽度应小部件加的间距width_multiplier
倍的高度在MainScreen
的孩子之间。我如何在Control
角色中使用MainScreen
的间隔属性? 我是基维新手,所以这可能是一个愚蠢的问题,但我希望有人能帮助我。
我不得不使用'self.parent.spacing [0]'因为它是一个列表。但感谢您的答案。不幸的是,我没有足够的声望来提高您的答案。 – FlopseyFlow
酷,固定到**间距[0] ** –