当前位置:网站首页>Kivy tutorial how to load kV file design interface by string (tutorial includes source code)
Kivy tutorial how to load kV file design interface by string (tutorial includes source code)
2022-07-03 13:20:00 【Knowledge fatness】
Actual combat needs
We sometimes need to be in a py In the file, run the code together with the interface configuration file ?
Solution
We can use Builder.load_string solve .
What is? Builder.load_string
stay Builder Insert a string into and return kv The root widget of the string
load_string ( string , ** kwargs )
Parameters
rulesonly: bool, defaults to False
If True, If you have a root widget in the definition , be Builder Exception will be thrown .filename: str, defaults to None
If specified , Is used for indexing kv File name of the rule .
filename Parameters can be used to uninstall kv Unload the file in the same way kv character string . This can be achieved using pseudo file names , for example :
Build.load_string("""
<MyRule>:
Label:
text="Hello"
""", filename="myrule.kv")
You can uninstall :
Build.unload_file("myrule.kv")
Combat code
from kivy.app import App
from kivy.lang import Builder
# File: clock.kv
KV = '''
BoxLayout:
orientation: 'vertical'
Label:
text: '00:00:00'
'''
class ClockApp(App):
def build(self):
return Builder.load_string(KV)
if __name__ == '__main__':
ClockApp().run()
边栏推荐
- Flink SQL knows why (7): haven't you even seen the ETL and group AGG scenarios that are most suitable for Flink SQL?
- 开始报名丨CCF C³[email protected]奇安信:透视俄乌网络战 —— 网络空间基础设施面临的安全对抗与制裁博弈...
- 刚毕业的欧洲大学生,就能拿到美国互联网大厂 Offer?
- 人身变声器的原理
- 2022-01-27 redis cluster brain crack problem analysis
- Servlet
- 显卡缺货终于到头了:4000多块可得3070Ti,比原价便宜2000块拿下3090Ti
- (first) the most complete way to become God of Flink SQL in history (full text 180000 words, 138 cases, 42 pictures)
- Tutoriel PowerPoint, comment enregistrer une présentation sous forme de vidéo dans Powerpoint?
- [Database Principle and Application Tutorial (4th Edition | wechat Edition) Chen Zhibo] [Chapter 7 exercises]
猜你喜欢

Sword finger offer 12 Path in matrix

When we are doing flow batch integration, what are we doing?

Flink SQL knows why (13): is it difficult to join streams? (next)

The difference between stratifiedkfold (classification) and kfold (regression)

Solve system has not been booted with SYSTEMd as init system (PID 1) Can‘t operate.

双链笔记 RemNote 综合评测:快速输入、PDF 阅读、间隔重复/记忆

PowerPoint tutorial, how to save a presentation as a video in PowerPoint?

Finite State Machine FSM

mysql更新时条件为一查询

When the R language output rmarkdown is in other formats (such as PDF), an error is reported, latex failed to compile stocks Tex. solution
随机推荐
php:&nbsp; The document cannot be displayed in Chinese
剑指 Offer 12. 矩阵中的路径
Smbms project
我的创作纪念日:五周年
R language uses the data function to obtain the sample datasets available in the current R environment: obtain all the sample datasets in the datasets package, obtain the datasets of all packages, and
Ubuntu 14.04 下开启PHP错误提示
Sitescms v3.0.2 release, upgrade jfinal and other dependencies
71 articles on Flink practice and principle analysis (necessary for interview)
JSP and filter
剑指 Offer 16. 数值的整数次方
Mysql database basic operation - regular expression
Logseq 评测:优点、缺点、评价、学习教程
R语言使用data函数获取当前R环境可用的示例数据集:获取datasets包中的所有示例数据集、获取所有包的数据集、获取特定包的数据集
阿南的疑惑
剑指 Offer 17. 打印从1到最大的n位数
Sword finger offer 14- ii Cut rope II
Fabric.js 更换图片的3种方法(包括更换分组内的图片,以及存在缓存的情况)
February 14, 2022, incluxdb survey - mind map
The difference between session and cookie
IDEA 全文搜索快捷键Ctr+Shift+F失效问题