简体   繁体   中英

Python IDLE. Auto-complete/Show completions not working

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.

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, ie 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.

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" , eg after a "QtGui.". Then a menu opens where you can arrow-scroll through the entries.

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM