<div dir="ltr">I'd like to have a way to dynamically define the code completion API based on context. Overriding <span style="font-family:monospace,monospace;font-size:x-small">updateAutoCompletionList</span> seems logical place to do this, but the following doesn't work: <div><br></div><div><div><font face="monospace, monospace" size="1">from PyQt5 import Qsci, QtWidgets</font></div><div><br></div><div><font face="monospace, monospace" size="1">class MyScriptApi(Qsci.QsciAPIs):</font></div><div><font face="monospace, monospace" size="1"> def updateAutoCompletionList(self, context: [str], options: [str]):</font></div><div><font face="monospace, monospace" size="1"> super().updateAutoCompletionList(context, options)</font></div><div><font face="monospace, monospace" size="1"> options.append('abcdefg')</font></div><div><br></div><div><span style="font-family:monospace,monospace;font-size:x-small">class Window(Qsci.QsciScintilla):</span><br></div><div><font face="monospace, monospace" size="1"> def __init__(self):</font></div><div><font face="monospace, monospace" size="1"> Qsci.QsciScintilla.__init__(self)</font></div><div><font face="monospace, monospace" size="1"> lexer = Qsci.QsciLexerPython(self)</font></div><div><font face="monospace, monospace" size="1"> api = MyScriptApi(lexer)</font></div><div><font face="monospace, monospace" size="1"> api.add('aLongString')</font></div><div><font face="monospace, monospace" size="1"> api.add('aLongString.abcd')</font></div><div><font face="monospace, monospace" size="1"> api.add('aLongerString')</font></div><div><font face="monospace, monospace" size="1"> api.add('aDifferentString')</font></div><div><font face="monospace, monospace" size="1"> api.add('sOmethingElse')</font></div><div><font face="monospace, monospace" size="1"> api.prepare()</font></div><div><font face="monospace, monospace" size="1"> self.setAutoCompletionThreshold(1)</font></div><div><font face="monospace, monospace" size="1"> self.setAutoCompletionSource(Qsci.QsciScintilla.AcsAPIs)</font></div><div><font face="monospace, monospace" size="1"> self.setLexer(lexer)</font></div><div><font face="monospace, monospace" size="1"><br></font></div><div><font face="monospace, monospace" size="1">if __name__ == "__main__":</font></div><div><span style="font-family:monospace,monospace;font-size:x-small"> import sys</span><br></div><div><font face="monospace, monospace" size="1"> app = QtWidgets.QApplication(sys.argv)</font></div><div><font face="monospace, monospace" size="1"> window = Window()</font></div><div><span style="font-family:monospace,monospace;font-size:x-small"> window.show()</span><br></div><div><font face="monospace, monospace" size="1"> app.exec_()</font></div><div><br></div><div>If the <span style="font-family:monospace,monospace;font-size:x-small">updateAutoCompletionList</span> is not defined (the class body is just "pass"), typing "a" shows several matches in the popup, but if the method is as shown above, no matches get shown, eventhough the base class method is called by the derived class. A breakpoint via debugger shows that base class method does not put anything in the options list, nor does the base class method return anything. </div><div><br></div><div>-- </div><div class="gmail_signature"><div dir="ltr"><font size="2">Oliver</font><div><font size="1">Author of these Open Source: <a href="http://pubsub.sf.net" target="_blank">PyPubSub</a>, L<a href="http://lua-icxx.sf.net" target="_blank">ua-iCxx</a>, <a href="http://iof.sf.net" target="_blank">iof</a></font></div><div><font size="1">Regular contributor on <a href="http://stackoverflow.com/users/869951/schollii" target="_blank">StackOverflow</a></font></div><div><br></div><div></div></div></div>
</div></div>