Skip to content

Instantly share code, notes, and snippets.

@el3
Last active March 27, 2019 12:05
Show Gist options
  • Save el3/709f431e6518fc9e29c91dbc6f54c9a6 to your computer and use it in GitHub Desktop.
Save el3/709f431e6518fc9e29c91dbc6f54c9a6 to your computer and use it in GitHub Desktop.
Kivy checkbox (radiobutton). How to make radiobuttons persistent (not deselect if pressed on when active)
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.checkbox import CheckBox
class CB(CheckBox):
def on_touch_down(self, *args):
if self.active:
return
super(CB, self).on_touch_down(*args)
KV = """
BoxLayout:
orientation: "vertical"
CB:
group: "one"
CB:
group: "one"
CB:
group: "one"
"""
class MyApp(App):
def build(self):
return Builder.load_string(KV)
MyApp().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment