Skip to content Skip to sidebar Skip to footer

Is It Possible To Read From More Than One .kv File In Kivy App?

I realize the short answer may be 'no,' but perhaps this is worth asking again. If I am witting a Kivy app with a couple thousand of lines - then would it be possible to write some

Solution 1:

Yes it is! You can import .kv files inside files just like normal python files by starting with:

#:include otherfile.kv

If you want the file to unload and reload first you can force the import typing

#:include force otherfile.kv

instead.

All this as written in the Kivy Language Documentation which is full of useful clarifications.

Solution 2:

Solution 3:

I believe you can create muliple .kv files and can include at one place (root file) by this way only you can distribute/branch your code Kivy documentation clearly says "A kv file must contain only one root widget at most" means only one kv main file. even if you run multiple instances of Mainapp class

I'm newer to the Kivy, so please correct me if I'm wrong. Thank you !

Post a Comment for "Is It Possible To Read From More Than One .kv File In Kivy App?"