当前位置:网站首页>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 字体不支持中文,
边栏推荐
- Pytorch extract middle layer features?
- MySQL stored procedure
- mysql高级(索引,视图,存储过程,函数,修改密码)
- Awk command exercise
- Detailed explanation of data types of MySQL columns
- Flink parsing (IV): recovery mechanism
- Unity小技巧 - 绘制瞄准准心
- Flexible report v1.0 (simple version)
- The solution to the left-right sliding conflict caused by nesting Baidu MapView in the fragment of viewpager
- C WinForm series button easy to use
猜你喜欢

基本磁盘与动态磁盘 RAID磁盘冗余阵列区分

Pyspark operator processing spatial data full parsing (4): let's talk about spatial operations first

The most complete tcpdump and Wireshark packet capturing practice in the whole network

Spark accumulator and broadcast variables and beginners of sparksql

Pytorch extract middle layer features?

FlutterWeb瀏覽器刷新後無法回退的解决方案

2021-03-22 "display login screen during recovery" can't be canceled. The appearance of lock screen interface leads to the solution that the remotely connected virtual machine can't work normally

学 SQL 必须了解的 10 个高级概念

TCP连接不止用TCP协议沟通

Easy introduction to SQL (1): addition, deletion, modification and simple query
随机推荐
Reppoints: advanced order of deformable convolution
Essai de pénétration du Code à distance - essai du module b
Display picture of DataGridView cell in C WinForm
酷雷曼多种AI数字人形象,打造科技感VR虚拟展厅
Example of batch update statement combining update and inner join in SQL Server
connection reset by peer
Unity tips - draw aiming Center
Application service configurator (regular, database backup, file backup, remote backup)
[translation] principle analysis of X Window Manager (I)
Kali2021 installation and basic configuration
03 products and promotion developed by individuals - plan service configurator v3.0
Openharmony developer documentation open source project
Flink parsing (III): memory management
[getting started with MySQL] fourth, explore operators in MySQL with Kiko
PyTorch 提取中间层特征?
SAP UI5 框架的 manifest.json
全网最全tcpdump和Wireshark抓包实践
[mmdetection] solves the installation problem
Zen integration nails, bugs, needs, etc. are reminded by nails
[rapid environment construction] openharmony 10 minute tutorial (cub pie)