from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import BooleanProperty
from kivy.lang import Builder
Builder.load_string('''
<MyWidget>:
CheckBox:
group: "Zone "
active: root.odrzuc
on_state: self.active
CheckBox:
group: "Zone "
active: root.decyduj
on_state: self.active
''')
class MyWidget(BoxLayout):
odrzuc = BooleanProperty(False)
decyduj = BooleanProperty(True)
class MyApp(App):
def build(self):
return MyWidget()
if __name__ == '__main__':
MyApp().run()
我想点击其中一个复选框,它会打开而另一个关闭。我可以使用'on_state:self.active'来阻止它们,但是当第二个被阻止时我不知道如何解锁它们,反之亦然。