kivy button on press call function

Solutions on MaxInterview for kivy button on press call function by the best coders in the world

showing results for - "kivy button on press call function"
Nicola
03 May 2018
1app.py:
2
3import kivy
4from kivy.app import App
5from kivy.uix.boxlayout import BoxLayout
6from kivy.uix.button import Button
7
8class Launch(BoxLayout):
9    def __init__(self, **kwargs):
10        super(Launch, self).__init__(**kwargs)
11
12    def say_hello(self): #<---- function that the button is calling
13        print "hello"
14
15
16class App(App):
17    def build(self):
18        return Launch()
19
20
21if __name__ == '__main__':
22    App().run()
23    
24app.kv:
25
26#:kivy 1.9.1
27
28<Launch>:
29    BoxLayout:
30        Button:
31            size:(80,80)
32            size_hint:(None,None)
33            text:"Click me"
34            on_press: say_hello() #<--- calls the say_hello() function
Bianca
06 Oct 2020
1import kivy
2from kivy.uix.widget import Widget
3from kivy.lang import Builder
4from kivymd.app import MDApp
5
6Builder.load_file('foo.kv')
7
8class layout1(Widget):
9  pass
10class App(MDApp):
11  def build(self):
12    self.theme_cls.theme_style = "Dark"
13    self.theme_cls.primary_palette = "BlueGray" 
14    return layout1()
15  def themeSwitch(self):# function that will be called from layout1() class
16    pass
17
18
19#kv file from here on.
20<layout1>
21	BoxLayout:
22		Button:
23          size_hint:(None,None)  
24          size:(80,80)
25          text:"Click me"
26          on_press: app.themeSwitch()
Vincenzo
31 Jun 2017
1button.bind(self.function)
queries leading to this page
kivy run and close a function with buttondef bottun pressed kivyrun a function on pressing kivy buttoncall function from button kivyclick button kivy pythonkivy link button to websitekivy call functionclick button kivykivy button use functionkivy on press buttonkivy bind button 5ckivy button call functionkivy call function on button presshow to bind number to a button to return answer kivy pythonhow to create a button in kivypython kivy change button callbackkivy buttonon press call functionkivy button on command function callkivy button to call funtionkivy python run functionskivy call function on button press one timeon press function kv fileboutton on press kivybutton onclick kivykivy on press call python functioncall a function kivypython react to kivy button presskivy buttonkivy button bind not workingon click kivycall button text kivycall a function when press button kivyinstance of 27button 27 has no 27bind 27kivy button on presskivy on button clickkivy button on presson press kivybutton on press kivybutton kivysenderbutton in kivykv button calls pythonpress with parameters kivyhow to know which button is clicked in kivy pythonhow to call a function in kivykivy button on press call functionhow to assign function to buttonn in kivyclick button to trigger kivyhow to call a function until a button is released in kivyhow to call a function from button press in kivykivy call widget on button presson click function in kivykivy button on press call function