def test_key_translation_to_builtin_key(self):
class SelectableText(urwid.Text):
def selectable(self): return True
def keypress(self, size, key): return key
list_contents = [SelectableText(str(i)) for i in range(1, 10)]
listw = self.km.wrap(urwid.ListBox, context='list')(urwid.SimpleFocusListWalker(list_contents))
self.km.bind(key='j', action=Key('down'))
self.assertEqual(listw.focus_position, 0)
listw.keypress((3, 3), 'j')
self.assertEqual(listw.focus_position, 1)
评论列表
文章目录