Toggle button

The ToggleButton widget acts like a checkbox. When you touch/click it, the state toggles between ‘normal’ and ‘down’ (opposed to a Button that is only ‘down’ as long as it is pressed).

Toggle buttons can also be grouped to make radio buttons - only one button in a group can be in ‘down’ state. The group name can be a string or any other hashable Python object

btn1 = ToggleButton(text='Male', group='sex',)
btn2 = ToggleButton(text='Female', group='sex', state='down')
btn3 = ToggleButton(text='Mixed', group='sex')

Only one of the buttons can be ‘down’/checked at the same time.

To configure the ToggleButton, you can use the same properties that you can use for a Button class.

class kivy.uix.togglebutton.ToggleButton(**kwargs)

Bases: kivy.uix.button.Button

Toggle button class, see module documentation for more information.

static get_widgets(groupname)

Return the widgets contained in a specific group. If the group doesn’t exist, an empty list will be returned.

Important

Always release the result of this method! In doubt, do:

l = ToggleButton.get_widgets('mygroup')
# do your job
del l

Warning

It’s possible that some widgets that you have previously deleted are still in the list. Garbage collector might need more elements before flushing it. The return of this method is informative, you’ve been warned!

New in version 1.3.0.

group

Group of the button. If None, no group will be used (button is independent). If specified, group must be a hashable object, like a string. Only one button in a group can be in ‘down’ state.

group is a ObjectProperty