how to implement a kv file by initializing a class

7 views
Skip to first unread message

Edward Anderson

unread,
Jan 27, 2026, 11:54:35 AM (3 days ago) Jan 27
to Kivy users support
I am attempting to divide a large project into individual steps with each step having its own kv file to format that step. The 3 attached files are organized so that MModel.py is the executive program that initializes a class in Directory.py with an attached prbdir,ky file.  Directory.py and prbdir.kv are in a subdirectory of the MModel.py directory. All of these are placed in a single Python package. When I run the Directory.py file, everything executes as intended with a label and title being displayed. When I execute the MModel.py file (Initializing the Directory class) only a blank screen (without label) is displayed. So, my question is how to implement a kv file by initializing a class?
prbdir.kv
Directory.py
MModel.py

ElliotG

unread,
Jan 27, 2026, 10:13:05 PM (3 days ago) Jan 27
to Kivy users support
You can pull a kv file into a python file a number of ways.
If the kv file has the same name as the app, it will load by default.
You can use Builder.load_file('pdbdir.kv')  to load a kv file explicitly
or use Builder.load_string(kv_string) to load kv.

to use Builder, use
from kivy.lang import Builder

Edward Anderson

unread,
Jan 28, 2026, 10:05:42 AM (2 days ago) Jan 28
to kivy-...@googlegroups.com
Hunter: Your description is exactly what I am trying to do.

Eliot: Your suggestion sound like what I need to do to accomplish my objective. I will try it when I get a chance.

Thanks to both of you.

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/kivy-users/c2f87b2c-2079-46fa-aa24-ac674fbd42f1n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages