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/self.list = CheckListCtrl(rightPanel)self.list.InsertColumn(0, 'Package', width=140)self.list.InsertColumn(1, 'Size')self.list.InsertColumn(2, 'Repository')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])vbox2 = wx.BoxSizer(wx.VERTICAL)sel = wx.Button(leftPanel, -1, 'Select All', size=(100, -1))des = wx.Button(leftPanel, -1, 'Deselect All', size=(100, -1))apply = wx.Button(leftPanel, -1, 'Apply', size=(100, -1))self.Bind(wx.EVT_BUTTON, self.OnSelectAll, id=sel.GetId())self.Bind(wx.EVT_BUTTON, self.OnDeselectAll, id=des.GetId())self.Bind(wx.EVT_BUTTON, self.OnApply, id=apply.GetId())vbox2.Add(sel, 0, wx.TOP, 5)vbox2.Add(des)vbox2.Add(apply)leftPanel.SetSizer(vbox2)vbox.Add(self.list, 1, wx.EXPAND | wx.TOP, 3)vbox.Add((-1, 10))vbox.Add(self.log, 0.5, wx.EXPAND)vbox.Add((-1, 10))rightPanel.SetSizer(vbox)hbox.Add(leftPanel, 0, wx.EXPAND | wx.RIGHT, 5)hbox.Add(rightPanel, 1, wx.EXPAND)hbox.Add((3, -1))panel.SetSizer(hbox)self.Centre()self.Show(True)def OnSelectAll(self, event):num = self.list.GetItemCount()for i in range(num):self.list.CheckItem(i)def OnDeselectAll(self, event):num = self.list.GetItemCount()for i in range(num):self.list.CheckItem(i, False)def OnApply(self, event):num = self.list.GetItemCount()for i in range(num):if i == 0: self.log.Clear()if self.list.IsChecked(i):self.log.AppendText(self.list.GetItemText(i) + '\n')app = wx.App()Repository(None, -1, 'Repository')app.MainLoop()20 de 21 27/04/2008 1:05

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

Saved successfully!

Ooh no, something went wrong!