Enhance the performance of your Kivy app 🚀 with lazy loading.
By implementing this template, you can enhance the performance of your Kivy app through the technique of lazy loading screens. Rather than loading all the screens at startup, this approach ensures that screens are loaded only when they are actively switched to. As a result, the startup time of your app can be significantly reduced.
This template also features a screen navigation system that simplifies handling the back button.
The Root
is based on ScreenManager
and additionally provides a few navigation methods: push(screen_name, side)
, push_replacement(screen_name, side)
and pop()
.
Also load_screen(screen_name)
method can be used to load the screen and the kv file without setting it as the current screen.
To incorporate additional screens into your app, follow these steps:
- Create
screen_file.py
in thelibs/uix/baseclass/
directory. - Create
screen_file.kv
in thelibs/uix/kv/
directory. - Add the screen details to
screens.json
as shown below:
{
...,
"screen_name": {
"import": "from libs.uix.baseclass.screen_file import ScreenObjectName",
"object": "ScreenObjectName()",
"kv": "libs/uix/kv/screen_file.kv"
}
}
This template already contains three screens as example which uses all the navigation methods.
To use this template for mobile devices, make sure to add json to your buildozer.spec
file, such as
# (list) Source files to include (let empty to include all the files)
source.include_exts = py,png,jpg,kv,atlas,gif,json