当前位置:网站首页>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 字体不支持中文,
边栏推荐
- Single responsibility principle
- Zen integration nails, bugs, needs, etc. are reminded by nails
- About selenium starting Chrome browser flash back
- 学 SQL 必须了解的 10 个高级概念
- Hongmeng introduction and development environment construction
- Xin'an Second Edition: Chapter 24 industrial control safety demand analysis and safety protection engineering learning notes
- Pyspark operator processing spatial data full parsing (5): how to use spatial operation interface in pyspark
- The art of Engineering
- Vscode replaces commas, or specific characters with newlines
- Flink parsing (VII): time window
猜你喜欢
The NTFS format converter (convert.exe) is missing from the current system
BearPi-HM_ Nano development environment
Yarn: unable to load file d:\programfiles\nodejs\yarn PS1, because running scripts is prohibited on this system
在一台服务器上部署多个EasyCVR出现报错“Press any to exit”,如何解决?
[translation] principle analysis of X Window Manager (I)
Selenium test of automatic answer runs directly in the browser, just like real users.
Re signal writeup
Flink parsing (IV): recovery mechanism
当前系统缺少NTFS格式转换器(convert.exe)
C version selenium operation chrome full screen mode display (F11)
随机推荐
Deploy flask project based on LNMP
Xin'an Second Edition: Chapter 26 big data security demand analysis and security protection engineering learning notes
Grafana 9 is officially released, which is easier to use and more cool!
OpenCV中如何使用滚动条动态调整参数
中移动、蚂蚁、顺丰、兴盛优选技术专家,带你了解架构稳定性保障
Essai de pénétration du Code à distance - essai du module b
Wordcloud colormap color set and custom colors
Huawei certified cloud computing hica
JMeter interface test response data garbled
C # nanoframework lighting and key esp32
Development and practice of lightweight planning service tools
【MySQL入门】第四话 · 和kiko一起探索MySQL中的运算符
Detailed explanation of data types of MySQL columns
Xin'an Second Edition: Chapter 25 mobile application security requirements analysis and security protection engineering learning notes
Unity小技巧 - 绘制瞄准准心
学 SQL 必须了解的 10 个高级概念
78 岁华科教授逐梦 40 载,国产数据库达梦冲刺 IPO
全网最全tcpdump和Wireshark抓包实践
Easy introduction to SQL (1): addition, deletion, modification and simple query
Guidelines for preparing for the 2022 soft exam information security engineer exam