Button — Kivy v1.0.1-dev documentation

# Button

The button is a `Label` with an action associated to it that is triggered when the button is pressed (or released after a click/touch). To configure the button, you can use the same properties that you can use for the Label class:

    button = Button(text='Hello world', font_size=14)

Attaching a callback when the button is pressed (clicked/touched)

    def callback(instance):
        print 'The button <%s> is being pressed' % instance.text

    btn1 = Button(text='Hello world 1')
    btn1.bind(on_press=callback)
    btn2 = Button(text='Hello world 2')
    btn2.bind(on_press=callback)

If you want to be notified every time the button state changes, you can attach to the `Button.state` property

    def callback(instance, value):
        print 'My button <%s> state is <%s>' % (instance, value)
    btn1 = Button(text='Hello world 1')
    btn1.bind(state=callback)

class `kivy.uix.button.` `Button`(**kwargs)

  Bases: `kivy.uix.label.Label`

  Button class, see module documentation for more information.

  Events : | on_press Fired when the button is pressed. on_release Fired when the button is released (i.e., the touch/click that pressed the button goes away).

  `state`

    State of the button, can be one of ‘normal’ or ‘down’. By default, the state of the button is ‘normal’.

    `state` is an `OptionProperty`.