From 61cb3244d453fe0907bb0001432b03d3fcc0db99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20D=C3=B6ring?= <30527984+radoering@users.noreply.github.com> Date: Fri, 6 May 2022 12:30:03 +0200 Subject: [PATCH] Fix CheckListBox GetSelections() --- etg/checklst.py | 9 +++++++++ unittests/test_checklst.py | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/etg/checklst.py b/etg/checklst.py index cbd763fb..1e3c2329 100644 --- a/etg/checklst.py +++ b/etg/checklst.py @@ -41,6 +41,15 @@ def run(): c.find('Create').findOverload('wxString choices').ignore() c.find('Create').findOverload('wxArrayString').find('choices').default = 'wxArrayString()' + c.addCppMethod('wxArrayInt*', 'GetSelections', '()', + isConst=True, factory=True, + doc="Returns a list of the indices of the currently selected items.", + body="""\ + wxArrayInt* array = new wxArrayInt; + self->GetSelections(*array); + return array; + """) + tools.fixWindowClass(c) diff --git a/unittests/test_checklst.py b/unittests/test_checklst.py index 90687505..54df3a30 100644 --- a/unittests/test_checklst.py +++ b/unittests/test_checklst.py @@ -45,6 +45,16 @@ class CheckListBoxTests(wtc.WidgetTestCase): c.CheckedStrings = ['three'] self.assertTrue(set(c.GetCheckedItems()) == set([2])) + def test_GetSelections(self): + c = wx.CheckListBox( + self.frame, + choices="one two three four".split(), + style=wx.LB_EXTENDED, + ) + self.assertEqual(c.GetSelections(), []) + c.SetSelection(2) + self.assertEqual(c.GetSelections(), [2]) + #---------------------------------------------------------------------------