I'd like to add VKeyboard widget for my app written using Kivy 1.9.0. I using Python 2.7.12. Is there a way to add this widget to application via kv language? Because while trying method below there is bug: 'ValueError: No JSON object could be decoded'
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
{ "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
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.