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 ListCtrlLeft(wx.ListCtrl):def __init__(self, parent, id):wx.ListCtrl.__init__(self, parent, id, style=wx.LC_REPORT | wx.LC_HRULES |wx.LC_NO_HEADER | wx.LC_SINGLE_SEL)images = ['icons/java.png', 'icons/gnome.png', 'icons/mozilla.png']self.parent = parentself.Bind(wx.EVT_SIZE, self.OnSize)self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnSelect)self.il = wx.ImageList(32, 32)for i in images:self.il.Add(wx.Bitmap(i))self.SetImageList(self.il, wx.IMAGE_LIST_SMALL)self.InsertColumn(0, '')for i in range(3):self.InsertStringItem(0, '')self.SetItemImage(0, i)def OnSize(self, event):size = self.parent.GetSize()self.SetColumnWidth(0, size.x-5)event.Skip()def OnSelect(self, event):window = self.parent.GetGrandParent().FindWindowByName('ListControlOnRight')index = event.GetIndex()window.LoadData(index)def OnDeSelect(self, event):index = event.GetIndex()self.SetItemBackgroundColour(index, 'WHITE')def OnFocus(self, event):self.SetItemBackgroundColour(0, 'red')class ListCtrlRight(wx.ListCtrl):def __init__(self, parent, id):wx.ListCtrl.__init__(self, parent, id, style=wx.LC_REPORT | wx.LC_HRULES |wx.LC_NO_HEADER | wx.LC_SINGLE_SEL)self.parent = parentself.Bind(wx.EVT_SIZE, self.OnSize)self.InsertColumn(0, '')def OnSize(self, event):size = self.parent.GetSize()self.SetColumnWidth(0, size.x-5)event.Skip()def LoadData(self, index):self.DeleteAllItems()for i in range(3):self.InsertStringItem(0, articles[index][i])class Reader(wx.Frame):def __init__(self, parent, id, title):wx.Frame.__init__(self, parent, id, title)16 de 21 27/04/2008 1:05

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

Saved successfully!

Ooh no, something went wrong!