【发布时间】:2019-04-25 14:06:05
【问题描述】:
我目前正在尝试触发嵌套在动态类中的一些小部件的事件。更加具体。这是一个示例 kv 文件:
<UserSelectionInput@BoxLayout>:
orientation: 'horizontal'
size_hint: None, 1
spacing: 4
lb_text: ''
lb_id: 'user_selection_label'
sp_values: '', ''
sp_id: 'user_selection_spinner'
Label:
id: root.lb_id
size_hint_x: 0.4
text: root.lb_text
Spinner:
id: root.sp_id
text: 'Select'
values: root.sp_values
<InnerBox@AnchorLayout>:
anchor_x: 'center'
anchor_y: 'center'
BoxLayout:
orientation: 'horizontal'
size_hint: None, 1
width: 2 * root.width / 3
spacing: 1
UserSelectionInput:
width: root.width / 3
sp_values: 'A', 'B', 'C'
lb_text: 'Type'
lb_id: 'label_1'
sp_id: 'spinner_1'
UserSelectionInput:
width: root.width / 3
sp_values: 'D', 'E', 'F', 'G'
lb_text: 'Version'
lb_id: 'label_2'
sp_id: 'spinner_2'
<MainContent>:
rows: 3
Label:
text: "Some Text"
GridLayout:
cols: 1
InnerBox:
我现在要做的是使用“InnerBox”布局内微调器的“on_text”事件从关联的 .py 文件中调用一个函数。我不确定这是否是最好的方法,但就可重用性而言,我想将动态类的概念用于某些小部件组合。
朱尔茨
【问题讨论】:
标签: python python-3.x kivy kivy-language