13.07.2015 Views

The wxPython tutorial

The wxPython tutorial

The wxPython tutorial

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Advanced widgetshttp://www.zetcode.com/wxpython/advanced/index = self.list.InsertStringItem(sys.maxint, data[0])self.list.SetStringItem(index, 1, data[1])self.list.SetStringItem(index, 2, data[2])self.list.SetItemData(index, key)hbox.Add(self.list, 1, wx.EXPAND)panel.SetSizer(hbox)self.Centre()self.Show(True)app = wx.App()Actresses(None, -1, 'actresses')app.MainLoop()We will again use the example with actresses.ColumnSorterMixin.__init__(self, len(actresses))<strong>The</strong> ColumnSorterMixin accepts one argument. It is the number of columnsto be sorted.self.itemDataMap = actressesWe must map our data to be displayed in a list control to the itemDataMapattribute. <strong>The</strong> data must be in a dictionary data type.def GetListCtrl(self):return selfWe must create a GetListCtrl() method. This method returns the wx.ListCtrlwidget that is going to be sorted.self.list.SetItemData(index, key)We must assosiate each row with a special index. This is done with theSetItemData method.ReaderA reader is a complex example showing two list controls in a report view.#!/usr/bin/python# reader.pyimport wxarticles = [['Mozilla rocks', '<strong>The</strong> year of the Mozilla', 'Earth on Fire'],['Gnome pretty, Gnome Slow', 'Gnome, KDE, Icewm, XFCE', 'Where is Gnome heading?'],['Java number one language', 'Compiled languages, intrepreted Languages', 'Java on D15 de 21 27/04/2008 1:05

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!