I'm new at kivy and try to run a do_login function inside my MyApp Class from a kv generated button.
my kv layout with the button
RelativeLayout:
    FloatingActionButton:
        id:                 float_act_btn
        on_press:           ???how to call call do_login from MyApp
and my class with the containing do_login function
class MyApp(App):
    def build(self):
        main_widget = Builder.load_string(login_kv) 
def do_login(self, *args):
    print'jo'
How to use on_press to call do_login?
with on_press:do_login(login.text, password.text)' I get 'do_login' is not defined and the same with self.do_login I get MaterialRaisedButton' object has no attribute 'do_login'
make do_login a member of the MyApp class:
class MyApp(App):
    def build(self):
        main_widget = Builder.load_string(login_kv) 
    def do_login(self, *args):
        print'jo'
and use app in kv as the keyword to access MyApp and call the function:
on_press: app.do_login()
from Kivy language:
There are three keywords specific to Kv language:
app: always refers to the instance of your application.
root: refers to the base widget/template in the current rule
self: always refer to the current widget
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With