Reputation: 995
self.list_box_1 = wx.ListBox(self, -1, choices = self.generateList("imagelist.txt"), style=wx.LB_SINGLE)
newlist=['6','7','8','9','10']
I have a listbox with filenames in it e.g. 1,2,3,4,5 and when a button is clicked I want the listbox to be cleared and the values of newlist overwrite the current values in the listbox
I can change each string in self.list_box_1 using self.list_box_1.SetString(5,1) but how do I overwrite the values in the listbox with the values in newlist
Upvotes: 1
Views: 1088
Reputation: 995
Thanks Phineas, I used
self.list_box_1.Clear()
self.list_box_1.InsertItems(newlist,0)
Upvotes: 1
Reputation: 3814
Also look for methods for the ListBox in the derivation hierarchy, like wx.ItemContainer
.
wx.ItemContainer.SetItems
might be helpful:
Clear and set the strings in the control from a list
Upvotes: 3