如何绑定到<Up>的Release<向下>或 Tkinter 中的其他键盘事件? [英] How to bind to the Release of <Up> <Down> or other keyboard events in Tkinter?

查看:15
本文介绍了如何绑定到<Up>的Release<向下>或 Tkinter 中的其他键盘事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在 Tkinter 中绑定到Up"和Down"事件,但我可以弄清楚如何绑定到这些事件的发布?

Im able to bind to "Up" and "Down" events in Tkinter, but i can figure out how to bind to the release of these events?

我正在做类似的事情:

Listbox.bind("<Up>", Update)

但这给了我列表框选择之前按下向上/向下键(如预期).有谁知道如何绑定到按键的释放?

But this is giving me the listbox selection before the Up/Down key was pressed (as expected). Does anyone know how to bind to the release of a key press?

提前致谢!

推荐答案

您可以使用 KeyPress-KeyRelease- 前缀键事件.例如.

You can prefix key events with KeyPress- or KeyRelease-. For example <KeyRelease-Up>.

如果您尝试使用它来获取选择,最好绑定到 <<>,它总是在选择更改后触发.

If you're trying to use this to get the selection, you are better off binding to <<ListboxSelect>> which always fires after the selection has changed.

这篇关于如何绑定到&lt;Up&gt;的Release&lt;向下&gt;或 Tkinter 中的其他键盘事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆