Python 空闲。自动完成/显示完成不起作用

发布于 2025-01-01 09:15:53 字数 641 浏览 2 评论 0原文

IDLE 对于何时实际显示自动完成菜单非常狡猾。到目前为止,它根本不起作用,或者更具体地说,仅在交互式会话期间起作用。

我一直在使用 C 代码块,并且已经真正习惯了非常好的自动完成功能,因此没有它们有点令人沮丧 - 特别是在尝试学习新框架以及与哪个类相关联时方法等等。

是否有一个简单的修复方法可以让 IDLE 自动完成再次工作?我使用的是Python 2.7版本。

也许有一个简单的编辑器我应该研究一下吗?我尝试过 Vim,它对于我的简单需求来说有点太重了,Ninja,我无法完成任何工作,还有 Sublime text 2,我无法使用我的 wxpython 东西来玩。一个不错的选择是什么?任何类似于代码块的东西都会很酷,不过,如果 IDLE 能够始终如一地工作,我会非常满意!

要求澄清: 好吧,看来我的一些术语可能倒退了。非交互式是指,例如,右键单击 python 文件并选择“使用 IDLE 编辑”。我猜这会带来一个文本编辑器。您可以在此处输入所有代码。准备好后,您可以按 F5,或选择“运行”,它会启动(我一直指的)交互式终端。您可以在这里输入代码,按回车键,然后立即评估该代码。

我的问题指的是前者,即 IDLE 中编辑代码的部分。有时在打字时,在 .它将显示可用的方法,或者在左括号后它将给出有关预期值的提示。但问题是,有时它会做这些事情,有时则不会。

IDLE is being very dodgy as to when it will actually show an Auto-complete menu. As of late it hasn't been working at all, or, more specifically, only works during an interactive session.

I've been using Code Blocks for C, and have gotten really used to the very nice auto-complete features, so it's a bit frustrating not having them -- especially while trying to learn a new frame work and what class is associated with which methods, etc, etc..

Is there an easy fix to get IDLE auto-complete working again? I'm using python version 2.7.

Is there perhaps a simple editor I should look into? I've tried Vim, which was a little too heavy for my simple needs, Ninja, which I couldn't get to work for anything, and Sublime text 2, which I couldn't get my wxpython stuff to play with. What would a nice option be? Anything similar to Code Blocks would be cool, although, I'd be perfectly happy with IDLE if it would consistently work!

REQUESTED CLARIFICATION:
OK, so it seems I may have some of my terminology backwards. By non-interactive, I mean, for instance, right clicking on a python file and selecting "edit with IDLE". This brings up what I guess could be described as a text editor. You can enter all you code here. Once ready, you then hit F5, or select Run, and it launches (what I've been referring to as) the interactive terminal. It's here that you can type in code, press return, and instantly have that code evaluated.

What my question is referring to it the former, the part of IDLE where you edit the code. Sometimes while typing, after a . it will display the available methods, or after an open parenthesis it'll give hints as to the values expected. but the thing is, sometimes it does these things, sometimes it doesn't.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

素手挽清风 2025-01-08 09:15:53

到目前为止我发现的唯一一件事是,如果 IDLE 的编辑会话与 python shell 连接(在问题中称为“交互模式”,即在尝试运行编辑的脚本之后),那么“非交互”IDLE 可以基于自动完成交互窗口中的值。例如,如果我输入

a = [];
a.appen

然后点击 <选项卡>它不会执行任何操作,但如果我之前输入

a = []

相应的 python shell,IDLE 将正确自动完成。

所以我唯一的建议是在 python shell 窗口中导入具有相同名称的相同模块,以使它们对非交互式 IDLE 编辑器“可见”。

The only thing i found so far is that if an editing session of IDLE is connected with python shell (called "interactive mode" in the question, i.e. after an attempt to run the edited script) then "non-interactive" IDLE can autocomplete based on values in interactive window. For example, if I type

a = [];
a.appen

and then hit < Tab > it will do nothing, but if I previously type

a = []

in corresponding python shell, IDLE will autocomplete correctly.

So my only suggestion is import same modules with same names in python shell window in order to make them "visible" for non-interactive IDLE editor.

一梦浮鱼 2025-01-08 09:15:53

我在 IDLE 上也遇到了同样的问题,因为我想学习 Qt,因此自动补全非常有用。

正如 IDLE 设置中所述,您可以使用“Control + Space”触发自动完成,例如在“QtGui”之后。然后会打开一个菜单,您可以在其中通过箭头滚动浏览条目。

I had the same problem with IDLE, because I want to learn Qt and therefore autocompletion is very useful.

As it says in the settings of IDLE, you can trigger the autocomplete with "Control + Space", e.g. after a "QtGui.". Then a menu opens where you can arrow-scroll through the entries.

混吃等死 2025-01-08 09:15:53

使用“空闲编辑器窗口”,您需要首先保存并执行代码。
应用程序运行后,返回编辑器窗口以使用自动完成功能。

using the 'IDLE Editor window', you need to save and execute your code first.
The application running, turn back to the Editor window to use the auto-completion.

川水往事 2025-01-08 09:15:53

有时这与您必须等待获得建议的时间有关。

当您转到选项>;扩展>一般completions popup wait处您可以将其更改为大约500ms。
就我而言,默认为 2000 毫秒。

Sometimes it has to do with the time you have to wait to get a suggestions.

When you go to options > extensions > general at completions popup wait you can change it to about 500ms.
In my case it was 2000ms by default.

花心好男孩 2025-01-08 09:15:53

就我而言,我必须打开“选项”菜单 ->编辑器上的“扩展”选项卡,并确保“自动完成”和其他相关选项已启用。他们实际上是这样,但是即使我不需要更改任何内容,只要单击“应用”就可以了。

In my case, I had to open Options menu -> Extensions tab on the editor and look to make sure AutoComplete and other relevant options were enabled. They actually were, but by just clicking on 'Apply' even though I dint have to change anything did the trick for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文