Fix CheckListBox GetSelections()

This commit is contained in:
Randy Döring
2022-05-06 12:30:03 +02:00
parent e5c47c8630
commit 61cb3244d4
2 changed files with 19 additions and 0 deletions

View File

@@ -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)

View File

@@ -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])
#---------------------------------------------------------------------------