如何在不同的小部件中使用属性? 我有这个密码:
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
的spacing属性?
我是新来基维,所以这可能是一个愚蠢的问题,但我希望有人能帮助我。你知道吗
在您的情况下,可以使用parent属性
相关问题 更多 >
编程相关推荐