是否可以在 Kivy 应用程序中读取多个 .kv 文件?

2023-06-07Python开发问题
18

本文介绍了是否可以在 Kivy 应用程序中读取多个 .kv 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我知道简短的回答可能是不",但也许这值得再问一次.

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 文件将是彼此的延续 - 不指向并行应用程序.

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.

这篇关于是否可以在 Kivy 应用程序中读取多个 .kv 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

在xarray中按单个维度的多个坐标分组
groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)...
2024-08-22 Python开发问题
15

Pandas中的GROUP BY AND SUM不丢失列
Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)...
2024-08-22 Python开发问题
17

pandas 有从特定日期开始的按月分组的方式吗?
Is there a way of group by month in Pandas starting at specific day number?( pandas 有从特定日期开始的按月分组的方式吗?)...
2024-08-22 Python开发问题
10

GROUP BY+新列+基于条件的前一行抓取值
Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)...
2024-08-22 Python开发问题
18

PANDA中的Groupby算法和插值算法
Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)...
2024-08-22 Python开发问题
11

PANAS-基于列对行进行分组,并将NaN替换为非空值
Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)...
2024-08-22 Python开发问题
10