Logger.trace crashes Unicode ListView

26 views
Skip to first unread message

Casper Lehmann

unread,
Jul 22, 2014, 4:26:43 AM7/22/14
to kivy-...@googlegroups.com
I wish to enable unicode in a selectable listview. My implementation works fine, which is to say I see the list, and one item is selected. But when I click on a list item. The app crashes.

Looking at the error log, I tried commenting out the following in lang.py, and that "solves" the problem:

1315        #if __debug__:
1316        #    trace('Builder: call_fn %s, key=%s, value=%r, %r' % (
1317        #        element, key, value, rule.value))

But I can't seem to make sense of the Logger module. So I'm stuck. The problem does not persist if I remove the Chinese characters.

This is the relevant part of my code:

list_item_args_converter = \
        lambda row_index, items_for_selection: {
                'text': u'字',
                'size_hint_y': None,
                'height': 25,
                'font_name': 'ukai.ttf'}

self.my_vocab_lists_list_adapter = \
        ListAdapter(
                data=[('tuples', 'of'),('data', 'stuff'),(u'啦', u'啦')],
                args_converter=list_item_args_converter,
                selection_mode='single',
                allow_empty_selection=False,
                cls=ListItemButton)



And the error:

Traceback (most recent call last):
   File "main.py", line 986, in <module>
     LuobiApp().run()
   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/kivy/app.py", line 792, in run
     runTouchApp()
   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/kivy/base.py", line 481, in runTouchApp
     EventLoop.window.mainloop()
   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/kivy/core/window/window_pygame.py", line 381, in mainloop
     self._mainloop()
   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/kivy/core/window/window_pygame.py", line 287, in _mainloop
     EventLoop.idle()
   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/kivy/base.py", line 324, in idle
     self.dispatch_input()
   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/kivy/base.py", line 309, in dispatch_input
     post_dispatch_input(*pop(0))
   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/kivy/base.py", line 220, in post_dispatch_input
     listener.dispatch('on_motion', etype, me)
   File "_event.pyx", line 316, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:4537)
   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/kivy/core/window/__init__.py", line 649, in on_motion
     self.dispatch('on_touch_up', me)
   File "_event.pyx", line 316, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:4537)
   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/kivy/core/window/__init__.py", line 675, in on_touch_up
     if w.dispatch('on_touch_up', touch):
   File "_event.pyx", line 316, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:4537)
   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/kivy/uix/screenmanager.py", line 1002, in on_touch_up
     return super(ScreenManager, self).on_touch_up(touch)
   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/kivy/uix/widget.py", line 306, in on_touch_up
     if child.dispatch('on_touch_up', touch):
   File "_event.pyx", line 316, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:4537)
   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/kivy/uix/relativelayout.py", line 219, in on_touch_up
     ret = super(RelativeLayout, self).on_touch_up(touch)
   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/kivy/uix/widget.py", line 306, in on_touch_up
     if child.dispatch('on_touch_up', touch):
   File "_event.pyx", line 316, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:4537)
   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/kivy/uix/widget.py", line 306, in on_touch_up
     if child.dispatch('on_touch_up', touch):
   File "_event.pyx", line 316, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:4537)
   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/kivy/uix/widget.py", line 306, in on_touch_up
     if child.dispatch('on_touch_up', touch):
   File "_event.pyx", line 316, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:4537)
   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/kivy/uix/scrollview.py", line 697, in on_touch_up
     self.simulate_touch_down(touch)
   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/kivy/uix/scrollview.py", line 508, in simulate_touch_down
     ret = super(ScrollView, self).on_touch_down(touch)
   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/kivy/uix/widget.py", line 284, in on_touch_down
     if child.dispatch('on_touch_down', touch):
   File "_event.pyx", line 316, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:4537)
   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/kivy/uix/widget.py", line 284, in on_touch_down
     if child.dispatch('on_touch_down', touch):
   File "_event.pyx", line 316, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:4537)
   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/kivy/uix/behaviors.py", line 92, in on_touch_down
     self._do_press()
   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/kivy/uix/behaviors.py", line 75, in _do_press
     self.state = 'down'
   File "properties.pyx", line 345, in kivy.properties.Property.__set__ (kivy/properties.c:3576)
   File "properties.pyx", line 377, in kivy.properties.Property.set (kivy/properties.c:4051)
   File "properties.pyx", line 431, in kivy.properties.Property.dispatch (kivy/properties.c:4644)
   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/kivy/lang.py", line 1317, in call_fn
     element, key, value, rule.value))
 UnicodeEncodeError: 'ascii' codec can't encode character u'\u6211' in position 33: ordinal not in range(128)

Reply all
Reply to author
Forward
0 new messages