【发布时间】:2017-01-16 22:07:03
【问题描述】:
我想为我使用 Kivy 1.9.0 编写的应用添加 VKeyboard 小部件。我使用 Python 2.7.12。有没有办法通过 kv 语言将此小部件添加到应用程序?因为在尝试下面的方法时存在错误:'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] ] }
【问题讨论】:
-
听起来 layout.json 不是有效的 json ...确保您遵循他们的示例 .... 或至少发布 layout.json
-
有 layout.json: { "title":"KeyboardPinyin", "description":"用于书写拼音字符的键盘", "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] }
标签: python widget kivy virtual-keyboard