当前位置:网站首页>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()
边栏推荐
- 开始报名丨CCF C³[email protected]奇安信:透视俄乌网络战 —— 网络空间基础设施面临的安全对抗与制裁博弈...
- SLF4J 日志门面
- Task5: multi type emotion analysis
- Servlet
- Fabric. JS three methods of changing pictures (including changing pictures in the group and caching)
- Solve system has not been booted with SYSTEMd as init system (PID 1) Can‘t operate.
- 解决 System has not been booted with systemd as init system (PID 1). Can‘t operate.
- MapReduce实现矩阵乘法–实现代码
- Sword finger offer 15 Number of 1 in binary
- C graphical tutorial (Fourth Edition)_ Chapter 20 asynchronous programming: examples - using asynchronous
猜你喜欢

MySQL functions and related cases and exercises

STM32 and motor development (from MCU to architecture design)

File uploading and email sending

(first) the most complete way to become God of Flink SQL in history (full text 180000 words, 138 cases, 42 pictures)

My creation anniversary: the fifth anniversary

Servlet

已解决(机器学习中查看数据信息报错)AttributeError: target_names

Today's sleep quality record 77 points

【历史上的今天】7 月 3 日:人体工程学标准法案;消费电子领域先驱诞生;育碧发布 Uplay

【数据库原理及应用教程(第4版|微课版)陈志泊】【第四章习题】
随机推荐
Sword finger offer 16 Integer power of numeric value
剑指 Offer 16. 数值的整数次方
已解决TypeError: Argument ‘parser‘ has incorrect type (expected lxml.etree._BaseParser, got type)
The difference between stratifiedkfold (classification) and kfold (regression)
C graphical tutorial (Fourth Edition)_ Chapter 18 enumerator and iterator: enumerator samplep340
IDEA 全文搜索快捷键Ctr+Shift+F失效问题
Today's sleep quality record 77 points
Flink SQL knows why (7): haven't you even seen the ETL and group AGG scenarios that are most suitable for Flink SQL?
[Database Principle and Application Tutorial (4th Edition | wechat Edition) Chen Zhibo] [Chapter IV exercises]
Anan's doubts
AI 考高数得分 81,网友:AI 模型也免不了“内卷”!
人身变声器的原理
Tutoriel PowerPoint, comment enregistrer une présentation sous forme de vidéo dans Powerpoint?
正则表达式
Asp.Net Core1.1版本没了project.json,这样来生成跨平台包
解决 System has not been booted with systemd as init system (PID 1). Can‘t operate.
Mysqlbetween implementation selects the data range between two values
Setting up Oracle datagurd environment
My creation anniversary: the fifth anniversary
Some thoughts on business