Skip to content

Commit 5eb076a

Browse files
authored
Merge pull request kivy#5020 from KeyWeeUsr/example_keyboard_fix
Fix file opening for vkeyboard
2 parents 3569e69 + ec94391 commit 5eb076a

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

examples/keyboard/main.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,11 @@ def key_down(self, keyboard, keycode, text, modifiers):
204204
# def key_up(self, keyboard, keycode):
205205
def key_up(self, keyboard, keycode, *args):
206206
""" The callback function that catches keyboard events. """
207-
self.displayLabel.text += u" (up {0[1]})".format(keycode)
207+
# system keyboard keycode: (122, 'z')
208+
# dock keyboard keycode: 'z'
209+
if isinstance(keycode, tuple):
210+
keycode = keycode[1]
211+
self.displayLabel.text += u" (up {0})".format(keycode)
208212

209213

210214
class KeyboardDemo(App):

kivy/uix/vkeyboard.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
from kivy.resources import resource_find
125125
from kivy.clock import Clock
126126

127+
from io import open
127128
from os.path import join, splitext, basename
128129
from os import listdir
129130
from json import loads
@@ -446,7 +447,7 @@ def _load_layout_fn(self, fn, name):
446447
available_layouts = self.available_layouts
447448
if fn[-5:] != '.json':
448449
return
449-
with open(fn, 'r') as fd:
450+
with open(fn, 'r', encoding='utf-8') as fd:
450451
json_content = fd.read()
451452
layout = loads(json_content)
452453
available_layouts[name] = layout

0 commit comments

Comments
 (0)