Last active
July 6, 2019 10:00
-
-
Save ckhung/2800b4090fd9228f36fd to your computer and use it in GitHub Desktop.
在 kivy 程式裡面顯示中文
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
title=zh_TW_test | |
author=ckhung | |
orientation=landscape |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# http://newtoypia.blogspot.tw/2015/07/kivy.html | |
import kivy | |
from kivy.app import App | |
from kivy.uix.button import Button | |
import kivy.resources | |
kivy.resources.resource_add_path('.') | |
class MyApp(App): | |
def build(self): | |
return Button(text=u'大大們安安', font_size=60, font_name=kivy.resources.resource_find('ukai.ttc')) | |
if __name__ == '__main__': | |
MyApp().run() |
u'大大們安安' 的 u 是指後面是 unicode 字串。 https://www.linuxtopia.org/online_books/programming_books/python_programming/python_ch12s02.html 從 python3 開始, 字串預設就是存成 utf8 , 所以那個 u 可以省略了: https://docs.python.org/3/howto/unicode.html
我改了一下 https://newtoypia.blogspot.com/2015/07/kivy.html 的文字,並且在這個 gist 加一個檔案,更明確地指出需要 main.py 跟 android.txt 這兩個檔案 (或是再加上 ukai.ttc)。 我只試過 label, 其他都沒試過。 這次我是在 essential ph-1 手機 lineage mata 作業系統上,安裝 kivy 1.9.0.0 上面 測試,是 ok 的。 這個最簡單陽春的版本,你成功嗎? 如果你試不出來, 請明確地描述你的 android 版本、 kivy 版本、 有沒有像其他範例一樣出現在 kivy 選單上、 ... 等等。 問問題時要提供詳細的資訊。
喔喔喔了解~,謝謝你拉~
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
是不是只能用Button
TextInput 或是 label