The KV language allows us to create our own widget tree in a declarative way and associate widget properties with each other or with callbacks in a natural way.
How to load the kv file: strong>
There are 2 ways to load
.kv file into code or application
When we write the code, we will make the App class. For this method, the file name and application class are the same, and save the kv file with
Kivy looks for a Kv file with the same name as your App class in lowercase, except for “App” if it ends in “App”, for example:
classnameApp --- & gt; classname.kv
If this file defines a root widget, it will be attached to the root attribute of the application and used as the base of the application widget tree.
Sample code on how to use the .kv file in kivy, below:
Save the .kv file code under the same name as the application class —
from kivy.lang import builder
The developer can now directly load the entire file as a string or file. Doing this to load the .kv file as a file:
Builder.load_file (`.kv / file / path`)
or, to load, the kv file as a string: