X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b1cfebd9f4fb3a63e4deab92c63f05b9706848a6..f94dd12dc18afd8518a88e9edac75f6dff907c9c:/wxPython/demo/wxListCtrl.py?ds=sidebyside diff --git a/wxPython/demo/wxListCtrl.py b/wxPython/demo/wxListCtrl.py index a97cf24a3f..bce9073e98 100644 --- a/wxPython/demo/wxListCtrl.py +++ b/wxPython/demo/wxListCtrl.py @@ -1,4 +1,3 @@ -#!/bin/env python #---------------------------------------------------------------------------- # Name: ListCtrl.py # Purpose: Testing lots of stuff, controls, window types, etc. @@ -12,7 +11,7 @@ #---------------------------------------------------------------------------- from wxPython.wx import * -from wxPython.lib.mixins.listctrl import wxColumnSorterMixin +from wxPython.lib.mixins.listctrl import wxColumnSorterMixin, wxListCtrlAutoWidthMixin #--------------------------------------------------------------------------- @@ -75,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) @@ -83,16 +91,16 @@ class TestListCtrlPanel(wxPanel, wxColumnSorterMixin): tID = wxNewId() self.il = wxImageList(16, 16) - bmp = images.getSmilesBitmap() - #idx1 = self.il.AddWithColourMask(bmp, wxWHITE) - idx1 = self.il.Add(bmp) - bmp = images.getSmallUpArrowBitmap() - self.sm_up = self.il.Add(bmp) - bmp = images.getSmallDnArrowBitmap() - self.sm_dn = self.il.Add(bmp) + idx1 = self.il.Add(images.getSmilesBitmap()) + self.sm_up = self.il.Add(images.getSmallUpArrowBitmap()) + self.sm_dn = self.il.Add(images.getSmallDnArrowBitmap()) + + #idx1 = self.il.AddIcon(wxIconFromXPMData(images.getSmilesData())) + #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) @@ -100,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") @@ -122,6 +130,7 @@ class TestListCtrlPanel(wxPanel, wxColumnSorterMixin): self.list.InsertColumnInfo(2, info) + items = musicdata.items() for x in range(len(items)): key, data = items[x] @@ -138,6 +147,7 @@ class TestListCtrlPanel(wxPanel, wxColumnSorterMixin): self.list.SetColumnWidth(0, wxLIST_AUTOSIZE) self.list.SetColumnWidth(1, wxLIST_AUTOSIZE) + self.list.SetColumnWidth(2, 100) # show how to select an item self.list.SetItemState(5, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED) @@ -222,6 +232,10 @@ class TestListCtrlPanel(wxPanel, wxColumnSorterMixin): 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") @@ -241,9 +255,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")