X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1b62f00d8e3ec5437ab780cb3d73d299cc61e20c..a7b09001af8d72c2c151ac01597965616b13b14c:/wxPython/demo/wxListBox.py diff --git a/wxPython/demo/wxListBox.py b/wxPython/demo/wxListBox.py index 11c21d9d90..f2f8bf7056 100644 --- a/wxPython/demo/wxListBox.py +++ b/wxPython/demo/wxListBox.py @@ -67,13 +67,15 @@ class TestListBox(wxPanel): EVT_LISTBOX_DCLICK(self, 60, self.EvtListBoxDClick) EVT_RIGHT_UP(self.lb1, self.EvtRightButton) self.lb1.SetSelection(3) + self.lb1.Append("with data", "This one has data"); + self.lb1.SetClientData(2, "This one has data"); wxStaticText(self, -1, "Select many:", wxPoint(200, 50), wxSize(65, 18)) self.lb2 = wxListBox(self, 70, wxPoint(280, 50), wxSize(80, 120), sampleList, wxLB_EXTENDED) EVT_LISTBOX(self, 70, self.EvtMultiListBox) - EVT_LISTBOX_DCLICK(self, 70, self.EvtListBoxDClick) + EVT_RIGHT_UP(self.lb2, self.EvtRightButton) self.lb2.SetSelection(0) @@ -89,6 +91,11 @@ class TestListBox(wxPanel): def EvtListBox(self, event): self.log.WriteText('EvtListBox: %s\n' % event.GetString()) + lb = event.GetEventObject() + data = lb.GetClientData(lb.GetSelection()) + if data is not None: + self.log.WriteText('\tdata: %s\n' % data) + def EvtListBoxDClick(self, event): self.log.WriteText('EvtListBoxDClick: %s\n' % self.lb1.GetSelection()) @@ -99,6 +106,12 @@ class TestListBox(wxPanel): def EvtRightButton(self, event): self.log.WriteText('EvtRightButton: %s\n' % event.GetPosition()) + if event.GetEventObject().GetId() == 70: + selections = list(self.lb2.GetSelections()) + selections.reverse() + for index in selections: + self.lb2.Delete(index) + #--------------------------------------------------------------------------- @@ -124,35 +137,4 @@ def runTest(frame, nb, log): overview = """\ A listbox is used to select one or more of a list of strings. The strings are displayed in a scrolling box, with the selected string(s) marked in reverse video. A listbox can be single selection (if an item is selected, the previous selection is removed) or multiple selection (clicking an item toggles the item on or off independently of other selections). -List box elements are numbered from zero. - -wxListBox() ---------------------- - -Default constructor. - -wxListBox(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, int n, const wxString choices[] = NULL, long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = "listBox") - -Constructor, creating and showing a list box. - -Parameters -------------------- - -parent = Parent window. Must not be NULL. - -id = Window identifier. A value of -1 indicates a default value. - -pos = Window position. - -size = Window size. If the default size (-1, -1) is specified then the window is sized appropriately. - -n = Number of strings with which to initialise the control. - -choices = An array of strings with which to initialise the control. - -style = Window style. See wxListBox. - -validator = Window validator. - -name = Window name. """