Is it possible to read from more than one .kv file in Kivy app?

Edv Beq picture Edv Beq · Mar 29, 2015 · Viewed 8.4k times · Source

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 classes in another kv file?

This would make it so much easier to edit, correct errors, make changes... etc.

Just to clarify - the .KV files would be a continuation of each other - not pointing to a parallel app.

Some expert insight would be greatly appreciated - Thank you.

Answer

Tadaboody picture Tadaboody · Nov 23, 2016

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.