X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/64be6958940c1aea9c69c386b6bac9eb463f60a9..f97c9b5bf2452c73434eb548e70115ac7ca60a83:/utils/wxPython/demo/wxListCtrl.py diff --git a/utils/wxPython/demo/wxListCtrl.py b/utils/wxPython/demo/wxListCtrl.py index 54477934b2..bd8487818c 100644 --- a/utils/wxPython/demo/wxListCtrl.py +++ b/utils/wxPython/demo/wxListCtrl.py @@ -23,7 +23,7 @@ class TestListCtrlPanel(wxPanel): tID = NewId() self.il = wxImageList(16, 16) - idx1 = self.il.Add(wxNoRefBitmap('bitmaps/smiles.bmp', wxBITMAP_TYPE_BMP)) + idx1 = self.il.Add(wxBitmap('bitmaps/smiles.bmp', wxBITMAP_TYPE_BMP)) self.list = wxListCtrl(self, tID, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxSUNKEN_BORDER) @@ -39,6 +39,7 @@ class TestListCtrlPanel(wxPanel): self.list.InsertImageStringItem(x, "This is item %d" % x, idx1) self.list.SetStringItem(x, 1, "Col 1, item %d" % x) self.list.SetStringItem(x, 2, "item %d in column 2" % x) + self.list.SetItemData(x, x*2) self.list.SetColumnWidth(0, wxLIST_AUTOSIZE) self.list.SetColumnWidth(1, wxLIST_AUTOSIZE) @@ -48,6 +49,7 @@ class TestListCtrlPanel(wxPanel): self.currentItem = 0 EVT_LIST_ITEM_SELECTED(self, tID, self.OnItemSelected) + EVT_LIST_DELETE_ITEM(self, tID, self.OnItemDelete) EVT_LEFT_DCLICK(self.list, self.OnDoubleClick) EVT_RIGHT_DOWN(self.list, self.OnRightDown) @@ -68,23 +70,34 @@ class TestListCtrlPanel(wxPanel): self.currentItem = event.m_itemIndex self.log.WriteText("OnItemSelected: %s\n" % self.list.GetItemText(self.currentItem)) + def OnItemDelete(self, event): + self.log.WriteText("OnItemDelete\n") + + def OnDoubleClick(self, event): self.log.WriteText("OnDoubleClick item %s\n" % self.list.GetItemText(self.currentItem)) def OnRightClick(self, event): self.log.WriteText("OnRightClick %s\n" % self.list.GetItemText(self.currentItem)) - self.menu = wxMenu() + menu = wxMenu() tPopupID1 = 0 tPopupID2 = 1 tPopupID3 = 2 - self.menu.Append(tPopupID1, "One") - self.menu.Append(tPopupID2, "Two") - self.menu.Append(tPopupID3, "Three") + tPopupID4 = 3 + tPopupID5 = 5 + menu.Append(tPopupID1, "One") + menu.Append(tPopupID2, "Two") + menu.Append(tPopupID3, "Three") + menu.Append(tPopupID4, "DeleteAllItems") + menu.Append(tPopupID5, "GetItem") EVT_MENU(self, tPopupID1, self.OnPopupOne) EVT_MENU(self, tPopupID2, self.OnPopupTwo) EVT_MENU(self, tPopupID3, self.OnPopupThree) - self.PopupMenu(self.menu, self.x, self.y) + EVT_MENU(self, tPopupID4, self.OnPopupFour) + EVT_MENU(self, tPopupID5, self.OnPopupFive) + self.PopupMenu(menu, wxPoint(self.x, self.y)) + menu.Destroy() def OnPopupOne(self, event): self.log.WriteText("Popup one\n") @@ -95,6 +108,13 @@ class TestListCtrlPanel(wxPanel): def OnPopupThree(self, event): self.log.WriteText("Popup three\n") + def OnPopupFour(self, event): + self.list.DeleteAllItems() + + def OnPopupFive(self, event): + item = self.list.GetItem(self.currentItem) + print item.m_text, item.m_itemId, self.list.GetItemData(self.currentItem) + def OnSize(self, event): w,h = self.GetClientSizeTuple() self.list.SetDimensions(0, 0, w, h)