Skip to content
Advertisement

Is there a way to call a function on screen load with kivy?

I have a kivy program where I need the labels to populate with the data given from a function within my screen class. It works with the update button properly however I would also like for it to populate the labels on load. Here is the python file and the kv file:

py:

JavaScript

.kv:

JavaScript

I have tried using things like clock to delay the function call outside of the class but that doesn’t help at all. Thanks for the help!

Advertisement

Answer

Thanks to a comment on my question I did some more research and reworked the code slightly and this were my findings for anyone else who is having this issue. I use on_pre_enter to call my function and within the function simply update the “label” variables I have to change the text within the kv file. Here is how it looks. I left some of the old code in but commented it out so you can see kind of how it looked before:

.py:

JavaScript

.kv

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement