当前位置:网站首页>kivy教程之在 Kivy 中支持中文以构建跨平台应用程序(教程含源码)
kivy教程之在 Kivy 中支持中文以构建跨平台应用程序(教程含源码)
2022-07-06 09:41:00 【知识大胖】
本教程讨论了在 Kivy 中支持中文,以便在使用诸如汉语、日语和韩语等UI 小部件上显示文本。
介绍
Kivy 是一个用于在 Python 中构建跨平台应用程序的库。使用相同的 Python 文件,可以创建 Windows、Linux、Mac、Android 和 iOS 应用程序。
默认情况下,Kivy 支持此链接https://github.com/kivy/kivy/tree/master/kivy/data/fonts中项目中可用的多种字体。当前支持的字体是 Roboto 和 DejaVu Sans。有许多国家在其官方语言中使用中文。
在标签小部件上显示中文
下一个 Python 代码创建了一个 Kivy 应用程序,其中窗口只有一个 Label 小部件,显示中文文本
import kivy.app
import kivy.uix.label
class TestApp(kivy.app.App):
def build(self):
return kivy.uix.label.Label(text="我爱北京天安门")
testApp = TestApp()
testApp.run()
运行此应用程序后的结果如下图所示,其中文本显示不正确。这意味着 Kivy 无法理解这些字符。当然,问题在于用于在 Label 小部件上显示文本的字体。

好消息是 Kivy 允许使用我们自己的字体在 UI 小部件上显示文本。如果默认的 Kivy 字体不支持中文,
边栏推荐
- Xin'an Second Edition: Chapter 23 cloud computing security requirements analysis and security protection engineering learning notes
- C # nanoframework lighting and key esp32
- Flink parsing (VII): time window
- EasyCVR电子地图中设备播放器loading样式的居中对齐优化
- The art of Engineering
- Uipath browser performs actions in the new tab
- 10 advanced concepts that must be understood in learning SQL
- Grafana 9 正式发布,更易用,更酷炫了!
- MySQL error reporting solution
- Guidelines for preparing for the 2022 soft exam information security engineer exam
猜你喜欢

Flink analysis (I): basic concept analysis

PySpark算子处理空间数据全解析(5): 如何在PySpark里面使用空间运算接口

当前系统缺少NTFS格式转换器(convert.exe)

02 personal developed products and promotion - SMS platform

面试突击63:MySQL 中如何去重?

Application service configurator (regular, database backup, file backup, remote backup)

SAP UI5 框架的 manifest.json

Summary of Android interview questions of Dachang in 2022 (II) (including answers)

Yarn: unable to load file d:\programfiles\nodejs\yarn PS1, because running scripts is prohibited on this system

Summary of Android interview questions of Dachang in 2022 (I) (including answers)
随机推荐
自动化运维利器ansible基础
Pytorch extract middle layer features?
Grafana 9 正式发布,更易用,更酷炫了!
FlutterWeb浏览器刷新后无法回退的解决方案
78 岁华科教授逐梦 40 载,国产数据库达梦冲刺 IPO
Growth of operation and maintenance Xiaobai - week 7
Unity tips - draw aiming Center
Solr appears write Lock, solrexception: could not get leader props in the log
[mmdetection] solves the installation problem
【MySQL入门】第一话 · 初入“数据库”大陆
一体化实时 HTAP 数据库 StoneDB,如何替换 MySQL 并实现近百倍性能提升
Openharmony developer documentation open source project
VR全景婚礼,帮助新人记录浪漫且美好的场景
Reppoints: advanced order of deformable convolution
Automatic operation and maintenance sharp weapon ansible Foundation
Spark accumulator and broadcast variables and beginners of sparksql
Awk command exercise
Total / statistics function of MySQL
About selenium starting Chrome browser flash back
Xin'an Second Edition; Chapter 11 learning notes on the principle and application of network physical isolation technology