<MyWidget>:
Button:
text: "Hello world, watch this text wrap inside the button"
text_size: self.size
font_size: '25sp'
markup: True
Button:
text: "Even absolute is relative to itself"
text_size: self.size
font_size: '25sp'
markup: True
Button:
text: "Repeating the same thing over and over in a comp = fail"
text_size: self.size
font_size: '25sp'
markup: True
在小部件中嵌入小部件没有错。您完全可以控制位置和大小。你知道吗
^{} 方法(和} 类的一部分,而^{} 只是从
children property
)是^{Widget
继承的。例如,Kivy pong tutorial没有任何布局。你知道吗注意:如果您开始怀疑使用} 的区别。基本上,后者是荣誉Widget.pos\u提示以及Widget.size\u提示属性。它允许您使用与
Widget
和^{Widget
大小成比例的值进行定位。你知道吗快速浏览一下Kv language documentation表明不需要,您不需要在小部件内设置布局。考虑一下他们给出的例子under the template section:
这里有3个按钮小部件直接放在
<MyWidget>
声明下面。你知道吗相关问题 更多 >
编程相关推荐