]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/demo/wxListCtrl.py
Tcl regex lib
[wxWidgets.git] / wxPython / demo / wxListCtrl.py
index 7e510dc04f09b0b4b262af5443b5fbb4694f003e..d1b9cf245f1f43899293fbf7fb1f75d06d192a2b 100644 (file)
@@ -105,7 +105,7 @@ class TestListCtrlPanel(wxPanel, wxColumnSorterMixin):
         self.list.SetImageList(self.il, wxIMAGE_LIST_SMALL)
 
         #  Why doesn't this show up on MSW???
-        self.list.SetToolTip(wxToolTip("This is a ToolTip!"))
+        #self.list.SetToolTip(wxToolTip("This is a ToolTip!"))
 
         if 0:
             # for normal, simple columns, you can add them like this:
@@ -163,6 +163,7 @@ class TestListCtrlPanel(wxPanel, wxColumnSorterMixin):
         self.currentItem = 0
         EVT_SIZE(self, self.OnSize)
         EVT_LIST_ITEM_SELECTED(self, tID, self.OnItemSelected)
+        EVT_LIST_ITEM_DESELECTED(self, tID, self.OnItemDeselected)
         EVT_LIST_ITEM_ACTIVATED(self, tID, self.OnItemActivated)
         EVT_LIST_DELETE_ITEM(self, tID, self.OnItemDelete)
         EVT_LIST_COL_CLICK(self, tID, self.OnColClick)
@@ -217,6 +218,13 @@ class TestListCtrlPanel(wxPanel, wxColumnSorterMixin):
             # this does
             self.list.SetItemState(10, 0, wxLIST_STATE_SELECTED)
 
+    # Show how to reselect something we don't want deselected
+    def OnItemDeselected(self, evt):
+        item = evt.GetItem()
+        if evt.m_itemIndex == 11:
+            wxCallAfter(self.list.SetItemState, 11, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED)
+
+
     def OnItemActivated(self, event):
         self.currentItem = event.m_itemIndex
         self.log.WriteText("OnItemActivated: %s\n" % self.list.GetItemText(self.currentItem))
@@ -228,7 +236,10 @@ class TestListCtrlPanel(wxPanel, wxColumnSorterMixin):
         self.log.WriteText("OnColClick: %d\n" % event.GetColumn())
 
     def OnColRightClick(self, event):
-        self.log.WriteText("OnColRightClick: %d\n" % event.GetColumn())
+        item = self.list.GetColumn(event.GetColumn())
+        self.log.WriteText("OnColRightClick: %d %s\n" %
+                           (event.GetColumn(), (item.GetText(), item.GetAlign(),
+                                                item.GetWidth(), item.GetImage())))
 
     def OnColBeginDrag(self, event):
         self.log.WriteText("OnColBeginDrag\n")
@@ -255,9 +266,12 @@ class TestListCtrlPanel(wxPanel, wxColumnSorterMixin):
         tPopupID3 = 2
         tPopupID4 = 3
         tPopupID5 = 5
-        #menu.Append(tPopupID1, "One")
+
+        # Show how to put an icon in the menu
         item = wxMenuItem(menu, tPopupID1,"One")
-        item.SetBitmap(images.getSmilesBitmap())
+        if wxPlatform == '__WXMSW__':
+            item.SetBitmap(images.getSmilesBitmap())
+
         menu.AppendItem(item)
         menu.Append(tPopupID2, "Two")
         menu.Append(tPopupID3, "Three")
@@ -274,6 +288,8 @@ class TestListCtrlPanel(wxPanel, wxColumnSorterMixin):
 
     def OnPopupOne(self, event):
         self.log.WriteText("Popup one\n")
+        print "FindItem:", self.list.FindItem(-1, "Roxette")
+        print "FindItemData:", self.list.FindItemData(-1, 11)
 
     def OnPopupTwo(self, event):
         self.log.WriteText("Popup two\n")
@@ -308,19 +324,17 @@ def runTest(frame, nb, log):
 
 
 
+overview = """\
+A list control presents lists in a number of formats: list view, report view, icon view and small icon view. Elements are numbered from zero.
 
+"""
 
 
 
 
 
+if __name__ == '__main__':
+    import sys,os
+    import run
+    run.main(['', os.path.basename(sys.argv[0])])
 
-
-
-
-
-
-overview = """\
-A list control presents lists in a number of formats: list view, report view, icon view and small icon view. Elements are numbered from zero.
-
-"""