Python Forum
[Kivy] Button - How to call functions - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: [Kivy] Button - How to call functions (/thread-8781.html)



Button - How to call functions - gio123 - Mar-07-2018

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


RE: Button - How to call functions - Barrowman - Mar-09-2018

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.