我正在使用 Urwid 按钮,想知道是否有办法直接在按钮上处理按键事件?
urwid.Button((item["customer"] + "/ " + item["case"]), button_press_pick_case,
user_data=item)
我知道我可以通过捕获 MainLoop 的 unhandled_input
然后找到当前聚焦的按钮来做到这一点,但我想知道是否有更简单的方法。
谢谢
最佳答案
看来对于全局快捷方式,真正的解决办法是unhandled_input
。
如果您想让按钮响应其他组合键,您可以编辑按钮的 CommandMap
,可通过 the _command_map
widget attribute 访问,但只有当按钮获得焦点时才会起作用。
关于python - 有没有办法从带有 Urwid 的按钮捕获按键?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45920356/