Kivy Text Input for Arabic Text(阿拉伯语文本的 Kivy 文本输入)
问题描述
我正在尝试将 Kivy 的文本输入用于阿拉伯文本.我用我的文本输入设置了一个阿拉伯字体,但是当我输入输入(阿拉伯语)时,我只是得到从左到右出现的阿拉伯字母(并且它们没有连接,因为阿拉伯字母应该是相邻的彼此).
有没有办法让 Kivy/文本输入支持我缺少的 RTL 语言输入(尤其是阿拉伯语).
这是我的代码,
从 kivy.app 导入 App从 kivy.uix.floatlayout 导入 FloatLayoutConfig.set('图形', '宽度', '300')Config.set('图形', '高度', '500')记录器 = logging.getLogger('')从 kivy.uix.textinput 导入 TextInput类编辑器应用程序(应用程序):定义构建(自我):f = 浮动布局()textinput = TextInput(text='Hello world', font_name='DroidKufi-Regular.ttf')#导入pdb;pdb.set_trace()f.add_widget(文本输入)返回 f如果 __name__ == '__main__':EditorApp().run()
这段代码的结果:
不幸的是,Kivy TextInput 对从右到左的支持是 的公开尝试.另一个封闭的:从右到左的标签支持.
I'm trying to use Kivy's text input for Arabic text. I have an Arabic font set up with my text input but when I type into the input (in Arabic) I just get Arabic letters appearing from left to right (and they're not connected as Arabic letters should be when they're adjacent to each other).
Is there a way to get Kivy/text input to support RTL languages input that I'm missing (esp Arabic).
Here's my code,
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
Config.set('graphics', 'width', '300')
Config.set('graphics', 'height', '500')
logger = logging.getLogger('')
from kivy.uix.textinput import TextInput
class EditorApp(App):
def build(self):
f = FloatLayout()
textinput = TextInput(text='Hello world', font_name='DroidKufi-Regular.ttf')
# import pdb; pdb.set_trace()
f.add_widget(textinput)
return f
if __name__ == '__main__':
EditorApp().run()
The result of this code:
Unfortunately, Kivy TextInput support for right-to-left is an open issue (checked 29/05/2015). Actually, Kivy is not supporting right-to-left not only to TextInput.
For static texts like labels , there is a hack by using arabic_reshaper and python-bidi (reference):
import arabic_reshaper
from bidi.algorithm import get_display
reshaped_text = arabic_reshaper.reshape(u'اللغة العربية رائعة')
bidi_text = get_display(reshaped_text)
Yet, as for TextInput
with a dynamic input, you had to override most of class methods to support RTL and you will end up like implementing the whole RTL support to kivy.
Here is an open attempt to implement Kivy bidi support. Another closed one: Right-to-left labels support.
这篇关于阿拉伯语文本的 Kivy 文本输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:阿拉伯语文本的 Kivy 文本输入


基础教程推荐
- 何时使用 os.name、sys.platform 或 platform.system? 2022-01-01
- 如何在海运重新绘制中自定义标题和y标签 2022-01-01
- Dask.array.套用_沿_轴:由于额外的元素([1]),使用dask.array的每一行作为另一个函数的输入失败 2022-01-01
- 在 Python 中,如果我在一个“with"中返回.块,文件还会关闭吗? 2022-01-01
- 筛选NumPy数组 2022-01-01
- 用于分类数据的跳跃记号标签 2022-01-01
- 使用PyInstaller后在Windows中打开可执行文件时出错 2022-01-01
- 线程时出现 msgbox 错误,GUI 块 2022-01-01
- Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll 2022-01-01
- 如何让 python 脚本监听来自另一个脚本的输入 2022-01-01