【发布时间】:2015-01-31 19:35:35
【问题描述】:
我的 Kivy 语言文件有许多 font_size 属性,都具有相同的值,是否可以在 KV lang 中分配变量? 当前 KV 文件示例:
#User ID
Label:
text: 'User ID'
font_size: 20
text_size: self.size
TextInput:
id: userid
font_size: 20
#User PW
Label:
text: 'Password'
font_size: 20
text_size: self.size
TextInput:
id: password
password: True
font_size: 20
Button:
text: 'Login'
font_size: 20
可以这样设置吗:
#User ID
@fs: 20
Label:
text: 'User ID'
font_size: fs
text_size: self.size
TextInput:
id: userid
font_size: fs
#User PW
Label:
text: 'Password'
font_size: fs
text_size: self.size
TextInput:
id: password
password: True
font_size: fs
Button:
text: 'Login'
font_size: fs
通过这样做,我只需更改 FS 变量值就可以立即更改字体大小,此外,类似的解决方案可能会帮助我更快地创建基于主题的文件。谢谢。
【问题讨论】:
标签: kivy