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 ?
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
# *******************************************************
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 ?
Is the completer object the one you got from Editra when we previously spoke?
The problem your seeing is from how the modules are structured in wxpython. wx.stc is not in the wx namespace until it is explicitly imported by the program at some point. So it won't show up for introspection if it has not yet been imported. If your Editor is using wx.stc though and the completer is running in the same python instance it will always show up since the import has happened in your program internally.
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 ?
Is the completer object the one you got from Editra when we previously spoke?
Sorry Cody, but in my current wxPython version,
I couldn't get yours completer to work,
neither in a standalone program , nor in Editra.
So I switched back to the standard builtin completer
(and because the interface is (almost?) the same for both completers,
it would be easy to change in the future.
The problem your seeing is from how the modules are structured in wxpython. wx.stc is not in the wx namespace until it is explicitly imported by the program at some point. So it won't show up for introspection if it has not yet been imported.
Thanks that explains,
but probably there are a few more of them ?
If your Editor is using wx.stc though and the completer is running in the same python instance it will always show up since the import has happened in your program internally.
Good point, never thought of that.
This only happened, when I made a small standalone program, to test some small extensions.
The problem your seeing is from how the modules are structured in wxpython. wx.stc is not in the wx namespace until it is explicitly imported by the program at some point. So it won't show up for introspection if it has not yet been imported.
Thanks that explains,
but probably there are a few more of them ?
I think wx.grid and any of the wx.lib modules would have this "issue" as well. There are probably a few more in the dark recesses of wxPython that I just don't use as well, such as any of the custom drawing stuff or that new Cairo interface that Robin just added. Looks like wx.gizmos might be one too...
Why not do instead:
left_path, right_part = word.rsplit('.', 1)
?
Good point, I never thought of such a statement.
But as this work in (early/slow) progress,
I always try to write things in the most clear/flexible way,
and as the left part might is assumed to be module,
which is not always true,
I need too shorten the left part later on
so I "word_parts".
thanks for the tip,
cheers,
Stef
···
On Mon, Sep 29, 2008 at 12:27 AM, Stef Mientki <s.mientki@ru.nl > <mailto:s.mientki@ru.nl>> wrote:
The problem your seeing is from how the modules are structured in wxpython. wx.stc is not in the wx namespace until it is explicitly imported by the program at some point. So it won't show up for introspection if it has not yet been imported.
Thanks that explains,
but probably there are a few more of them ?
I think wx.grid and any of the wx.lib modules would have this "issue" as well. There are probably a few more in the dark recesses of wxPython that I just don't use as well, such as any of the custom drawing stuff or that new Cairo interface that Robin just added. Looks like wx.gizmos might be one too...
Yep they suffer from the same problem.
Is that the rason why a number of IDEs have so much trouble with wxPython ?
Would be good to have a complete list, so you can add them manually for code completion.
The problem your seeing is from how the modules are structured in wxpython. wx.stc is not in the wx namespace until it is explicitly imported by the program at some point. So it won't show up for introspection if it has not yet been imported.
Thanks that explains,
but probably there are a few more of them ?
I think wx.grid and any of the wx.lib modules would have this "issue" as well. There are probably a few more in the dark recesses of wxPython that I just don't use as well, such as any of the custom drawing stuff or that new Cairo interface that Robin just added. Looks like wx.gizmos might be one too...
Yep they suffer from the same problem.
Is that the rason why a number of IDEs have so much trouble with wxPython ?
Would be good to have a complete list, so you can add them manually for code completion.
I suppose that could be one reason, but I'd have to know what the problems were to really be able to comment on it. I do know that Wingware's IDE seems to play fine with wxPython. It's a little grumpy about some of wx's warnings, but you tell Wing to ignore them and it will happily go on its merry little way.