[英]Kivy- kv language VKeyboard
I'd like to add VKeyboard widget for my app written using Kivy 1.9.0. 我想为使用Kivy 1.9.0编写的应用程序添加VKeyboard小部件。 I using Python 2.7.12.
我使用Python 2.7.12。 Is there a way to add this widget to application via kv language?
有没有办法通过kv语言将此小部件添加到应用程序? Because while trying method below there is bug: 'ValueError: No JSON object could be decoded'
因为在尝试下面的方法时有错误:'ValueError:没有JSON对象可以被解码'
Button:
background_color:1,0,0,0.5
text:'Next word'
size_hint:.5,.2
font_size:25
pos_hint:{'center_x':.5}
on_press:root.word_dict()
VKeyboard:
layout:'layout.json'
layout.json layout.json
{ "title":"KeyboardPinyin", "description":"Keyboard using for writing pinyin characters", "cols":5, "rows":3, "normal_1":[ ["ā","ā","ā",1], ["ē","ē","ē",1], ["ī","ī","ī",1], ["ō","ō","ō",1], ["ū","ū","ū",1] ], "normal_2": [ ["á","á","á",1], ["é","é","é",1], ["í","í","í",1], ["ó","ó","ó",1], ["ú","ú","ú",1] ], "normal_3": [ ["ǎ","ǎ","ǎ",1], ["ě","ě","ě",1], ["ǐ","ǐ","ǐ",1], ["ǒ","ǒ","ǒ",1], ["ǔ","ǔ","ǔ",1] ], "normal_4": [ ["à","à","à",1], ["è","è","è",1], ["ì","ì","ì",1], ["ò","ò","ò",1], ["ù","ù","ù",1] ] }
Traceback (most recent call last):
File "C:/Users/joran/.PyCharm50/config/scratches/scratch_33", line 3, in <module>
data = json.load(open(os.path.expanduser("~/layout1.json")))
File "C:\Python27\lib\json\__init__.py", line 290, in load
**kw)
File "C:\Python27\lib\json\__init__.py", line 338, in loads
return _default_decoder.decode(s)
File "C:\Python27\lib\json\decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Python27\lib\json\decoder.py", line 382, in raw_decode
obj, end = self.scan_once(s, idx)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xe1 in position 0: unexpected end of data
you cannot it tries to decode the input using utf8 ... you have non-utf8 characters in your json 你不能尝试使用utf8解码输入...你的json中有非utf8字符
you should instead use the unicode representation "\à"
etc (or you must somehow specify the character encoding of the json ... I am not sure how you might do that offhand) 你应该使用unicode表示
"\à"
等(或者你必须以某种方式指定json的字符编码......我不知道你怎么可能这样做)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.