From b0d5e2d8759d7c2f4c70ada20ea605fe45935f2b Mon Sep 17 00:00:00 2001 From: Scott Talbert Date: Fri, 27 Apr 2018 20:40:47 -0400 Subject: [PATCH] Fix subclassing of wx.TextCompleter and wx.TextCompleterSimple Closes https://github.com/wxWidgets/Phoenix/issues/827 --- CHANGES.rst | 2 ++ etg/textcompleter.py | 2 ++ unittests/test_textcompleter.py | 40 +++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 unittests/test_textcompleter.py diff --git a/CHANGES.rst b/CHANGES.rst index d20288c2..32e2a205 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -61,6 +61,8 @@ Changes in this release include the following: * Fixed bug in wx.lib.intctrl (#790) +* Fixed subclassing of wx.TextCompleter and wx.TextCompleterSimple (#827) + diff --git a/etg/textcompleter.py b/etg/textcompleter.py index 6d678560..38210206 100644 --- a/etg/textcompleter.py +++ b/etg/textcompleter.py @@ -35,8 +35,10 @@ def run(): c = module.find('wxTextCompleter') assert isinstance(c, etgtools.ClassDef) c.addPrivateCopyCtor() + c.addDefaultCtor(prot='public') c = module.find('wxTextCompleterSimple') + c.addDefaultCtor(prot='public') # TODO: Change GetCompletions to return the wxArrayString instead of # passing it as a parameter? diff --git a/unittests/test_textcompleter.py b/unittests/test_textcompleter.py new file mode 100644 index 00000000..bd7e7844 --- /dev/null +++ b/unittests/test_textcompleter.py @@ -0,0 +1,40 @@ +import unittest +from unittests import wtc +import wx + + +#--------------------------------------------------------------------------- + +class testcompleter_Tests(wtc.WidgetTestCase): + + def test_textcompleterClasses(self): + wx.TextCompleter + wx.TextCompleterSimple + + def test_textCompleter1(self): + class MyTextCompleter(wx.TextCompleter): + def __init__(self): + wx.TextCompleter.__init__(self) + def Start(self, prefix): + return False + def GetNext(self): + return '' + t = wx.TextCtrl(self.frame) + t.AutoComplete(MyTextCompleter()) + + def test_textCompleterSimple(self): + class MyTextCompleterSimple(wx.TextCompleterSimple): + def __init__(self): + wx.TextCompleterSimple.__init__(self) + def GetCompletions(self, prefix, res): + res.append("one") + res.append("two") + t = wx.TextCtrl(self.frame) + t.AutoComplete(MyTextCompleterSimple()) + + +#--------------------------------------------------------------------------- + + +if __name__ == '__main__': + unittest.main()