当前位置:网站首页>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()
边栏推荐
- Sitescms v3.1.0 release, launch wechat applet
- Tencent cloud tdsql database delivery and operation and maintenance Junior Engineer - some questions of Tencent cloud cloudlite certification (TCA) examination
- Kivy教程之 如何通过字符串方式载入kv文件设计界面(教程含源码)
- 106. 如何提高 SAP UI5 应用路由 url 的可读性
- rxjs Observable filter Operator 的实现原理介绍
- Red Hat Satellite 6:更好地管理服务器和云
- 我的创作纪念日:五周年
- My creation anniversary: the fifth anniversary
- 【历史上的今天】7 月 3 日:人体工程学标准法案;消费电子领域先驱诞生;育碧发布 Uplay
- [Database Principle and Application Tutorial (4th Edition | wechat Edition) Chen Zhibo] [Chapter V exercises]
猜你喜欢

Comprehensive evaluation of double chain notes remnote: fast input, PDF reading, interval repetition / memory

Flink SQL knows why (XI): weight removal is not only count distinct, but also powerful duplication

Introduction to the implementation principle of rxjs observable filter operator

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

Mysql database basic operation - regular expression
![[Database Principle and Application Tutorial (4th Edition | wechat Edition) Chen Zhibo] [sqlserver2012 comprehensive exercise]](/img/47/78d9dd098dcb894ba1f459873d5f52.png)
[Database Principle and Application Tutorial (4th Edition | wechat Edition) Chen Zhibo] [sqlserver2012 comprehensive exercise]

Resolved (error in viewing data information in machine learning) attributeerror: target_ names

My creation anniversary: the fifth anniversary

18W word Flink SQL God Road manual, born in the sky

Sword finger offer 14- ii Cut rope II
随机推荐
SLF4J 日志门面
CVPR 2022 image restoration paper
有限状态机FSM
对业务的一些思考
Kivy教程之 如何通过字符串方式载入kv文件设计界面(教程含源码)
SQL learning notes (I)
SSH登录服务器发送提醒
今日睡眠质量记录77分
高效能人士的七个习惯
Today's sleep quality record 77 points
[colab] [7 methods of using external data]
Sword finger offer 11 Rotate the minimum number of the array
8皇后问题
Logseq evaluation: advantages, disadvantages, evaluation, learning tutorial
C graphical tutorial (Fourth Edition)_ Chapter 20 asynchronous programming: examples - using asynchronous
Task6: using transformer for emotion analysis
OpenHarmony应用开发之ETS开发方式中的Image组件
Image component in ETS development mode of openharmony application development
Asp.Net Core1.1版本没了project.json,这样来生成跨平台包
Some thoughts on business