From 9d73df7b775bbe3ac856190528226a7e38cae41f Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 22 May 2012 00:17:53 +0000 Subject: [PATCH] Add wx.adv.EditableListBox git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@71532 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- etg/_adv.py | 2 +- etg/editlbox.py | 62 ++++++++++++++++++++++++++++++++++++++ unittests/test_editlbox.py | 36 ++++++++++++++++++++++ 3 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 etg/editlbox.py create mode 100644 unittests/test_editlbox.py diff --git a/etg/_adv.py b/etg/_adv.py index 3b6d72bb..f44a9a88 100644 --- a/etg/_adv.py +++ b/etg/_adv.py @@ -38,13 +38,13 @@ INCLUDES = [ 'joystick', 'animate', 'bannerwindow', + 'editlbox', # TODOs - # These modules are also in the C++ adv lib and so should be included here: # #'bmpcbox', - #'editlbox', #'laywin', #'notifmsg', #'odcombo', diff --git a/etg/editlbox.py b/etg/editlbox.py new file mode 100644 index 00000000..c53bc6ce --- /dev/null +++ b/etg/editlbox.py @@ -0,0 +1,62 @@ +#--------------------------------------------------------------------------- +# Name: etg/editlbox.py +# Author: Robin Dunn +# +# Created: 21-May-2012 +# Copyright: (c) 2012 by Total Control Software +# License: wxWindows License +#--------------------------------------------------------------------------- + +import etgtools +import etgtools.tweaker_tools as tools + +PACKAGE = "wx" +MODULE = "_adv" +NAME = "editlbox" # Base name of the file to generate to for this script +DOCSTRING = "" + +# The classes and/or the basename of the Doxygen XML files to be processed by +# this script. +ITEMS = [ "wxEditableListBox", + ] + +#--------------------------------------------------------------------------- + +def run(): + # Parse the XML file(s) building a collection of Extractor objects + module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING) + etgtools.parseDoxyXML(module, ITEMS) + + #----------------------------------------------------------------- + # Tweak the parsed meta objects in the module object as needed for + # customizing the generated code and docstrings. + + c = module.find('wxEditableListBox') + assert isinstance(c, etgtools.ClassDef) + tools.fixWindowClass(c) + + c.find('wxEditableListBox.label').default = 'wxEmptyString' + c.find('Create.label').default = 'wxEmptyString' + + module.addHeaderCode('#include ') + module.addGlobalStr('wxEditableListBoxNameStr', c) + + c.find('GetStrings').ignore() + c.addCppMethod('wxArrayString*', 'GetStrings', '()', + doc="Returns a list of the current contents of the control.", + body="""\ + wxArrayString* arr = new wxArrayString; + self->GetStrings(*arr); + return arr;""", + factory=True) + + + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + +#--------------------------------------------------------------------------- +if __name__ == '__main__': + run() + diff --git a/unittests/test_editlbox.py b/unittests/test_editlbox.py new file mode 100644 index 00000000..8ec9d894 --- /dev/null +++ b/unittests/test_editlbox.py @@ -0,0 +1,36 @@ +import imp_unittest, unittest +import wtc +import wx +import wx.adv + +#--------------------------------------------------------------------------- + +class editlbox_Tests(wtc.WidgetTestCase): + + def test_editlbox1(self): + wx.adv.EL_ALLOW_NEW + wx.adv.EL_ALLOW_EDIT + wx.adv.EL_ALLOW_DELETE + wx.adv.EL_NO_REORDER + wx.adv.EL_DEFAULT_STYLE + + def test_editlbox2(self): + elb = wx.adv.EditableListBox(self.frame, label="EditableListBox") + strings = "one two three four five".split() + elb.SetStrings(strings) + self.assertEqual(strings, elb.GetStrings()) + self.assertEqual(strings, elb.Strings) + + def test_editlbox3(self): + elb = wx.adv.EditableListBox() + elb.Create(self.frame, label="EditableListBox") + strings = "one two three four five".split() + elb.SetStrings(strings) + self.assertEqual(strings, elb.GetStrings()) + self.assertEqual(strings, elb.Strings) + + +#--------------------------------------------------------------------------- + +if __name__ == '__main__': + unittest.main()