問題描述
我知道簡短的回答可能是不",但也許這值得再問一次.
I realize the short answer may be 'no,' but perhaps this is worth asking again.
如果我知道一個有幾千行的 Kivy 應用程序 - 那么是否可以在另一個 kv 文件中編寫一些類?
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.
澄清一下 - .KV 文件將是彼此的延續(xù) - 不指向并行應用程序.
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.
推薦答案
是的!您可以像普通的 python 文件一樣在文件中導入 .kv
文件,方法是:
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
相反.
所有這些都寫在 Kivy 語言文檔中,其中充滿了有用澄清.
All this as written in the Kivy Language Documentation which is full of useful clarifications.
這篇關(guān)于是否可以在 Kivy 應用程序中讀取多個 .kv 文件?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!