hi folks, i'm new here so please excuse me if my question is totally dumb...
I have installed drpython (3.10.12) with codecompletion plugin (0.2.1), and i want to try out the completion feature...
maybe i don't have understood the way the plugin works, but when i create a class like that
if __name__ == "__main__":
object == foo()
object. <- i expected the plugin to complete by "bar()" but there's nothing appearing... despite the fact that the plugin seems to be loaded and functionnal.
maybe something i missed ?
thx for your advices
is the Code Completition enabled? (Options => Enable Code Completition).
Does after typing wx. pop up a completition list?
For the object: Python is weak typed, so normally
you cannot say, what type object is.
BTW: You meant object = foo(); not object == foo()? ;)
It could be achieved, but never accurate.
this means a more complex reparsing the source.
I think I was able to make it work by making GetMembers() compile the entire code.
See modified source below for GetMembers() and OnAutoComplete() :
if not DrFrame.CodeCompletion:
stc = DrFrame.GetActiveSTC()
if (stc.filetype != 0):
word, wordalias = GetWordOfInterest(stc, True)
documentText = stc.GetText()
if (wordalias.find("gtk") > -1) or (wordalias.find("drpython") > -1):
#This crashes wxPython resp. drPython
results = GetMembers(documentText, word)
#if wordalias != word:
# results = GetMembers(documentText, wordalias, prepend=word)
# results = GetMembers(documentText, word)
if len(results) < 1:
def GetMembers(documentText, word, filename='', prepend=''):
# Compile the entire document.
# - Otherwise, the exec() statement won't know
# - about previously created variables, their values
# - and/or their types
exec(compile(documentText, "", "exec"))
exec(compile("import " + word, filename, 'exec'))
# Determine the autocomplete list for the given word
exec(compile("members = dir(" + word + ")", filename, 'exec'))
if len(prepend) == 0:
prepend = word
results = ''
for m in members:
results = prepend + '.' + m + ' ' + results
I tried your patch, but it doesn't seem to
work. (I hope, I made no mistake).
If I type
and then wx.
But it would be cool, if you (want and/or have time)
to investigate this issue.
Maybe Pycrust's code completion would be helpful