Merge pull request #5020 from KeyWeeUsr/example_keyboard_fix

Fix file opening for vkeyboard
This commit is contained in:
matham 2017-02-27 19:01:51 -05:00 committed by GitHub
commit 5eb076a317
2 changed files with 7 additions and 2 deletions

View File

@ -204,7 +204,11 @@ class KeyboardScreen(Screen):
# def key_up(self, keyboard, keycode):
def key_up(self, keyboard, keycode, *args):
""" The callback function that catches keyboard events. """
self.displayLabel.text += u" (up {0[1]})".format(keycode)
# system keyboard keycode: (122, 'z')
# dock keyboard keycode: 'z'
if isinstance(keycode, tuple):
keycode = keycode[1]
self.displayLabel.text += u" (up {0})".format(keycode)
class KeyboardDemo(App):

View File

@ -124,6 +124,7 @@ from kivy.core.image import Image
from kivy.resources import resource_find
from kivy.clock import Clock
from io import open
from os.path import join, splitext, basename
from os import listdir
from json import loads
@ -446,7 +447,7 @@ class VKeyboard(Scatter):
available_layouts = self.available_layouts
if fn[-5:] != '.json':
return
with open(fn, 'r') as fd:
with open(fn, 'r', encoding='utf-8') as fd:
json_content = fd.read()
layout = loads(json_content)
available_layouts[name] = layout