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/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 = AutoWidthListCtrl(panel)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 actresses: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()We change the previous example a bit.from wx.lib.mixins.listctrl import ListCtrlAutoWidthMixinHere we import the mixin.class AutoWidthListCtrl(wx.ListCtrl, ListCtrlAutoWidthMixin):def __init__(self, parent):wx.ListCtrl.__init__(self, parent, -1, style=wx.LC_REPORT)ListCtrlAutoWidthMixin.__init__(self)We create a new AutoWidthListCtrl class. This class will inherit fromwx.ListCtrl and ListCtrlAutoWidthMixin. This is called multiple inheritance.<strong>The</strong> last column will automatically resize to take up the remaining width of awx.ListCtrl.13 de 21 27/04/2008 1:05

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

Saved successfully!

Ooh no, something went wrong!