]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/demo/wxListCtrl.py
Added wxIEHtmlWin wrappers to wxPython.
[wxWidgets.git] / wxPython / demo / wxListCtrl.py
index 41645a29c3a5a7b328d87255fb978e6c550a3bdb..9c23d2e6749d5d8b21b849682e96f0c5674a6586 100644 (file)
@@ -11,7 +11,7 @@
 #----------------------------------------------------------------------------
 
 from wxPython.wx import *
-from wxPython.lib.mixins.listctrl import wxColumnSorterMixin
+from wxPython.lib.mixins.listctrl import wxColumnSorterMixin, wxListCtrlAutoWidthMixin
 
 #---------------------------------------------------------------------------
 
@@ -74,6 +74,15 @@ musicdata = {
 
 import images
 
+
+class TestListCtrl(wxListCtrl, wxListCtrlAutoWidthMixin):
+    def __init__(self, parent, ID, pos=wxDefaultPosition,
+                 size=wxDefaultSize, style=0):
+        wxListCtrl.__init__(self, parent, ID, pos, size, style)
+        wxListCtrlAutoWidthMixin.__init__(self)
+
+
+
 class TestListCtrlPanel(wxPanel, wxColumnSorterMixin):
     def __init__(self, parent, log):
         wxPanel.__init__(self, parent, -1, style=wxWANTS_CHARS)
@@ -91,7 +100,7 @@ class TestListCtrlPanel(wxPanel, wxColumnSorterMixin):
         #self.sm_up = self.il.AddIcon(wxIconFromXPMData(images.getSmallUpArrowData()))
         #self.sm_dn = self.il.AddIcon(wxIconFromXPMData(images.getSmallDnArrowData()))
 
-        self.list = wxListCtrl(self, tID,
+        self.list = TestListCtrl(self, tID,
                                style=wxLC_REPORT|wxSUNKEN_BORDER)#|wxLC_VRULES|wxLC_HRULES)
         self.list.SetImageList(self.il, wxIMAGE_LIST_SMALL)
 
@@ -99,7 +108,7 @@ class TestListCtrlPanel(wxPanel, wxColumnSorterMixin):
         self.list.SetToolTip(wxToolTip("This is a ToolTip!"))
 
         if 0:
-            # for normal simple columns, you can add them like this:
+            # for normal, simple columns, you can add them like this:
             self.list.InsertColumn(0, "Artist")
             self.list.InsertColumn(1, "Title", wxLIST_FORMAT_RIGHT)
             self.list.InsertColumn(2, "Genre")
@@ -219,10 +228,17 @@ 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")
+        ## Show how to not allow a column to be resized
+        #if event.GetColumn() == 0:
+        #    event.Veto()
+
 
     def OnColDragging(self, event):
         self.log.WriteText("OnColDragging\n")
@@ -242,9 +258,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")
@@ -295,19 +314,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.
-
-"""