13.07.2015 Views

The wxPython tutorial

The wxPython tutorial

The wxPython tutorial

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Advanced widgetshttp://www.zetcode.com/wxpython/advanced/wx.LC_SORT_DESCENDINGwx.LC_HRULESwx.LC_VRULESSimple exampleIn the first example we will introduce basic functionality of a wx.ListCtrl.#!/usr/bin/python# actresses.pyimport wximport syspackages = [('jessica alba', 'pomona', '1981'), ('sigourney weaver', 'new york', '1949'),('angelina jolie', 'los angeles', '1975'), ('natalie portman', 'jerusalem', '1981'),('rachel weiss', 'london', '1971'), ('scarlett johansson', 'new york', '1984' )]class Actresses(wx.Frame):def __init__(self, parent, id, title):wx.Frame.__init__(self, parent, id, title, size=(380, 230))hbox = wx.BoxSizer(wx.HORIZONTAL)panel = wx.Panel(self, -1)self.list = wx.ListCtrl(panel, -1, style=wx.LC_REPORT)self.list.InsertColumn(0, 'name', width=140)self.list.InsertColumn(1, 'place', width=130)self.list.InsertColumn(2, 'year', wx.LIST_FORMAT_RIGHT, 90)for i in packages:index = self.list.InsertStringItem(sys.maxint, i[0])self.list.SetStringItem(index, 1, i[1])self.list.SetStringItem(index, 2, i[2])hbox.Add(self.list, 1, wx.EXPAND)panel.SetSizer(hbox)self.Centre()self.Show(True)app = wx.App()Actresses(None, -1, 'actresses')app.MainLoop()self.list = wx.ListCtrl(panel, -1, style=wx.LC_REPORT)We create a wx.ListCtrl with a wx.LC_REPORT style.self.list.InsertColumn(0, 'name', width=140)self.list.InsertColumn(1, 'place', width=130)self.list.InsertColumn(2, 'year', wx.LIST_FORMAT_RIGHT, 90)We insert three columns. We can specify the width of the column and theformat of the column. <strong>The</strong> default format is wx.LIST_FORMAT_LEFT.11 de 21 27/04/2008 1:05

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

Saved successfully!

Ooh no, something went wrong!