Python/Tkinter:通过键盘/鼠标捕获文本选择作为事件? [英] Python/Tkinter: Trap text selection via keyboard/mouse as an event?

查看:33
本文介绍了Python/Tkinter:通过键盘/鼠标捕获文本选择作为事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将通过键盘和鼠标进行的文本选择捕获为 selection/selection_change 类型的事件?(我知道我可以通过观察每个按键并比较选择范围来通过键盘捕获选择 - 但我看不到通过鼠标或作为离散事件本身检测选择的方法)

Is it possible to trap text selection via the keyboard AND mouse as a selection/selection_change type of event? (I know I can trap selection via the keyboard by watching every keypress and comparing selection range - but I see no way to detect selection via the mouse or as a discrete event by itself)

我查看了以下 Tkinter 事件文档,但没有看到 selection/selection_changed 类型的事件.http://infohost.nmt.edu/tcc/help/pubs/tkinter/events.html

I've looked at the following Tkinter event documentation and don't see a selection/selection_changed type of event. http://infohost.nmt.edu/tcc/help/pubs/tkinter/events.html

也许你们中的一些 Tkinter/Tk 老手可能有一些聪明的想法?

Perhaps some of you Tkinter/Tk veterans might have some clever ideas?

谢谢,马尔科姆

推荐答案

文本小部件生成 <> 事件,列表框生成 <<;ListboxSelect>> 事件.两者是否满足您的需求?

The text widget generates a <<Selection>> event, and the listbox generates a <<ListboxSelect>> event. Do either of those meet your needs?

这篇关于Python/Tkinter:通过键盘/鼠标捕获文本选择作为事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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