]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/wxPython/demo/wxListCtrl.py
1. Grid cell defaults are now handled by an internal
[wxWidgets.git] / utils / wxPython / demo / wxListCtrl.py
index 790a88ce2334198d2fd4a15090c0c8482cd9817a..bd8487818c49c6e5184f399e1c9231976e5212e4 100644 (file)
@@ -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)
@@ -79,20 +80,24 @@ class TestListCtrlPanel(wxPanel):
 
     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
         tPopupID4 = 3
-        self.menu.Append(tPopupID1, "One")
-        self.menu.Append(tPopupID2, "Two")
-        self.menu.Append(tPopupID3, "Three")
-        self.menu.Append(tPopupID4, "DeleteAllItems")
+        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)
         EVT_MENU(self, tPopupID4, self.OnPopupFour)
-        self.PopupMenu(self.menu, wxPoint(self.x, self.y))
+        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")
@@ -106,6 +111,10 @@ class TestListCtrlPanel(wxPanel):
     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)