rlcompleter and wxPython, problems ...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Stef Mientki

    rlcompleter and wxPython, problems ...

    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_completion s ( 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.Com pleter ( locals () )
    State = 0
    Next = Completer.compl ete ( word, State )
    result = []
    while Next :
    result.append ( Next )
    State += 1
    Next = Completer.compl ete ( word, State )

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


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

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

Working...