【发布时间】:2021-04-19 06:56:00
【问题描述】:
目前我正在学习 Kivy,并且我已经阅读了关于 kv lang 的 documentation。但我不太了解 kv 规则:
想问:
- 什么是根规则
- 如何声明根规则以及在哪里声明
- 可以举一些例子:)?
like : 在 .kv 文件中
#:kivy 2.0.0
<main>: ----------------------------------------- <-- class rule
Label: -------------------------------------- <-- root rule
text: "Hello World !" <-- child of Label
font_size: 70 <-- child of Label
center_x: root.width /2 <-- child of Label
center_y: root.height /2 <-- child of Label
BoxLayout: ---------------------------------- <-- root rule
size: root.width /2, root.height /3 <-- child of BoxLayout
Button: <-- child of BoxLayout
text: "Button 1" <-- child of Button
font_size: 30 <-- child of Button
Button: <-- child of BoxLayout
text: "Button 2" <-- child of Button
font_size: 30 <-- child of Button
是这样的吗?
【问题讨论】: