我试图通过MDMenuItem更改标签文本,但失败了,呵呵
以下是我正在尝试的:
.kv文件
<MDMenuItem>:
on_release: app.change_label(self.text)
MyLabel:
id: unilabel
text: app.label_weight
font_size: 12.5
MDIconButton:
id: unibutton
icon: 'arrow-down-drop-circle'
on_release: MDDropdownMenu(items=app.menu_labels_weight, width_mult=2).open(self)
main.py
class NoNameApp(App):
label_weight = 'Label Text'
menu_labels_weight = [
{"viewclass": 'MDMenuItem',
'text': 'g'},
{"viewclass": 'MDMenuItem',
'text': 'Kg'},
{'viewclass': 'MDMenuItem',
'text': 'ml'},
{'viewclass': 'MDMenuItem',
'text': 'L'},
{'viewclass': 'MDMenuItem',
'text': 'Unidade(s)'}
]
def change_label(self, value):
self.label_weight = value
但我得到:
AttributeError: 'MDMenuItem' object has no attribute 'callback'
我知道现在我应该在“menu\u label\u weight”dict上放置一个回调键,但是当我这样做时,我无法在我的App类中调用该函数
有人能帮我解决这个问题吗
目前没有回答
相关问题 更多 >
编程相关推荐