rlcompleter and wxPython, problems ...

S

Stef Mientki

hello,

I'm trying to implement autocompletion into my editor.
But I find some weird behavior,
or at least I don't have the faintest idea why this behavior occures,
and even more important how to solve it
In the example below I try to autocomplete " wx.s" , which in my humble
opinion should at least produce "wx.stc" (and some others ).

The completion is done in a procedure, so the "locals" is quite clean.
Before calling the completer, I import the left part of my string to be
completed.
The program below gives indeed "wx.stc" as an option,
but if I leave the second line out, marker "<<<===" ,
I get no results.

Can someone explain this behavior and
maybe even have a solution ?

thanks,
Stef Mientki


import rlcompleter
import wx.stc # <<<===

# ***********************************************************************
# ***********************************************************************
def _get_completions ( word ) :
left_part = None
right_part = word
if word.find('.') >= 0 :
word_parts = word.split('.')
left_part = '.'.join ( word_parts [ : -1 ] )
right_part = word_parts [ -1 ]

try :
exec ( 'import ' + left_part )
except :
return None

Completer = rlcompleter.Completer ( locals () )
State = 0
Next = Completer.complete ( word, State )
result = []
while Next :
result.append ( Next )
State += 1
Next = Completer.complete ( word, State )

result = ' '.join ( result )
return result
# ***********************************************************************


# ***********************************************************************
# ***********************************************************************
if __name__ == "__main__":

word = 'wx.s'
completions = _get_completions ( word )
print completions
# *******************************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top