Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.

like image 688
Edv Beq Avatar asked Mar 29 '15 18:03

Edv Beq


People also ask

How many ways can the .KV file be loaded into code or application?

There are two ways to load the . kv file into code or an Application.

What is a .KV file?

A KV file is a Kivy language file created by Kivy, an open-source Python library used to develop multi-touch enabled, cross-platform applications. It stores source code in the Kivy syntax, which may include rule definitions, a root widget, dynamic class definitions, and templates.


1 Answers

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.

like image 58
Tadaboody Avatar answered Oct 04 '22 21:10

Tadaboody