Python Forum

Full Version: Button - How to call functions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi All,
Using Kivy I need to call a function by pressing a Button. At the moment this code work fine but only to end the program execution.

from kivy.uix.button import Button
....

b=(Button(text='Exit'))
Layout.add_widget(b)
b.bind(on_press=exit)
For example I would like to call a function for changing the text of a label.

Thanks in advance for your kind support.
Regards,

Giovanni
Well you have bound that button to the exit function. If you want to do something else with that button write the function and bind it to that one instead. Otherwise create the function you want as well and create another button and bind that one to the new function.