【发布时间】:2015-07-24 00:44:53
【问题描述】:
我想知道什么?
- 如果释放 id 为 button_b(Get_Boys 类)的按钮,则必须更改 id 为 label_g(Get_Girls 类)的标签。
- 如果按下 id 为 button_b(Get_Boys 类)的按钮,则必须更改 id 为 root_lbl(Get_People 类)的标签。
- 如果释放 id 为 root_btn(Get_People 类)的 Button,则 id 为 label_b(Get_Boys 类)的标签必须更改。
在this链接中有解释(很少),但不是从初学者的角度。
我有 2 个文件
- test.py
- dates_test.kv
test.py
class Get_People(BoxLayout):
pass
class Get_Boys(BoxLayout):
pass
class Get_Girls(BoxLayout):
pass
class TestApp(App):
def build(self):
self.load_kv('dates_test.kv')
return Get_People()
dates_test.kv 文件
<Get_People>:
orientation: 'vertical'
Button:
name: root_btn
id: root_btn
text: "I am Root Button"
on_release: change_label_b
Label:
id: root_lbl
text: "I am Root Label"
Get_Boys:
Get_Girls:
<Get_Boys>:
Button:
id: button_b
text: "Button for boys"
on_press: change_label_root
on_release: change_label_g
Label:
id: label_b
text: "Label for boys"
<Get_Girls>:
Button:
id: button_g
text: "Button for girls"
Label:
id: label_g
text:"Label for girls"
【问题讨论】:
标签: python events button widget kivy