我尝试在两个或多个标签之间建立一个切换,比如单选按钮。到目前为止,它可以通过ToggleButtonBehavior来改变组之间的状态,但是当我单击所选项目时,它将被取消选择,不应该这样做。在
class SelectButton(ToggleButtonBehavior, Label):
active = BooleanProperty(False)
def __init__(self, **kwargs):
super(SelectButton, self).__init__(**kwargs)
self.text='off'
self.color=[1,0,1,1]
self.bind(state=self.toggle)
def toggle(self, instance, value):
if self.state == 'down':
self.text = 'on'
else:
self.text = 'off'
有没有办法让你的行为像单选按钮?在
有一个^{} property :
将其设置为
False
并使用组后,一切都开始按预期工作:相关问题 更多 >
编程相关推荐