Python IDE IDLE 如何在光标位置的文本小部件顶部显示自动完成列表? [英] How does Python IDE IDLE shows autocompletion list on top of text widget at cursor position?

查看:25
本文介绍了Python IDE IDLE 如何在光标位置的文本小部件顶部显示自动完成列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否使用列表框?上下文菜单?在文本中插入小部件?还有什么?

Is it using listbox? context-menu? inserting widgets within text? something else?

另外,是否有一些关于 IDLE 功能的文档?哪些 python 文件做什么等?

Also, is there some documentation about how IDLE functions? Which python files do what, etc?

推荐答案

autocompletewindow 是一个带有 Listbox 的 tk Toplevel>滚动条.代码位于 idlelib/AutoCompleteWindow.py(以及 AutoComplete.py 中的相关代码).

The autocompletewindow is a tk Toplevel with a Listbox and Scrollbar. Code is in idlelib/AutoCompleteWindow.py (and associated code in AutoComplete.py).

空闲文档提供空闲的用户视图.没有文档给出了 idlelib 的程序员视图.(我希望在我开始使用 Idle 时有一个.现在我了解了大多数文件的作用,我应该写点东西.)

The Idle doc gives a user view of Idle. There is no doc giving a programmer view of idlelib. (I wish there had been one when I started with Idle. Now that I understand what most of the files do, I should write something.)

Tk 和 Toplevel 小部件通过传递 几何字符串.geometry (== .wm_geometry) 方法.请注意,字符串的 'wxh' 部分可以省略,只传递 '+x+y',就像在空闲代码中一样.

Tk and Toplevel widgets are located with respect to the desktop by passing a geometry string to the .geometry (== .wm_geometry) method. Note that the 'wxh' part of the string can be omitted to just pass '+x+y', as in the Idle code.

CallTipWindow.position_window 根据 widget.winfo_rootx/y文本.bbox 和一个偏移量.如果调用提示是通过键入 ( 触发的,则框位于该字符周围.AutoCompleteWindow.winconfig_event 执行类似操作,但也使用 winfo_width/height方法.

CallTipWindow.position_window calculates x and y from widget.winfo_rootx/y and Text.bbox and an offset. If the calltip is triggered by typing (, the box is around that character. AutoCompleteWindow.winconfig_event does something similar, but also uses winfo_width/height methods.

EDIT 2:弹出菜单可以用 Menu.post(x, y), (或 Menu.tk_popup) 定位,其中 x, y 是相对于根的.(工作示例)

EDIT 2: Popup menus can be positioned with Menu.post(x, y), (or Menu.tk_popup) where x, y are relative to root. (Working example)

这篇关于Python IDE IDLE 如何在光标位置的文本小部件顶部显示自动完成列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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