Tkinter文本小部件插入光标 [英] The Tkinter Text Widget Insertion Cursor

查看:114
本文介绍了Tkinter文本小部件插入光标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在Tkinter Text小部件中获取插入光标的y坐标?我正在尝试制作一个在插入光标旁边弹出的弹出菜单.

Is it possible to get the x y coordinates of the insertion cursor in a Tkinter Text widget? I'm trying to make a popup menu that pops up next to the insertion cursor.

推荐答案

bbox方法可用于获取索引的边界框.您可以使用它来获取相对于窗口的位置.您可以使用winfo方法获取窗口的x/y.

The bbox method can be used to get the bounding box of an index. You can use that to get the position relative to the window. You can use the winfo method to get the x/y of the window.

通常弹出窗口显示在鼠标旁边,而不是插入点旁边(尽管通常情况下,右键单击会先设置插入点,然后显示菜单).

Typically popups appear next to the mouse rather than the insertion point (though typically, right-clicking first sets the insertion point and then displays a menu).

这篇关于Tkinter文本小部件插入光标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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