keymap_test.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:stig 作者: rndusr 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号