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/Figure: ReaderCheckListCtrlIt is quite common to see applications having check boxes inside listcontrols. For example a packaging application like Synaptic or KYUM.From the programmer's point of view, those checkboxes are simple images.<strong>The</strong>re are two states. Checked and unchecked. For both situations we have aunique image. We do not have to implement the functionality. It has beenalready coded. <strong>The</strong> code is in CheckListCtrlMixin.#!/usr/bin/python# repository.pyimport wximport sysfrom wx.lib.mixins.listctrl import CheckListCtrlMixin, ListCtrlAutoWidthMixinpackages = [('abiword', '5.8M', 'base'), ('adie', '145k', 'base'),('airsnort', '71k', 'base'), ('ara', '717k', 'base'), ('arc', '139k', 'base'),('asc', '5.8M', 'base'), ('ascii', '74k', 'base'), ('ash', '74k', 'base')]class CheckListCtrl(wx.ListCtrl, CheckListCtrlMixin, ListCtrlAutoWidthMixin):def __init__(self, parent):wx.ListCtrl.__init__(self, parent, -1, style=wx.LC_REPORT | wx.SUNKEN_BORDER)CheckListCtrlMixin.__init__(self)ListCtrlAutoWidthMixin.__init__(self)class Repository(wx.Frame):def __init__(self, parent, id, title):wx.Frame.__init__(self, parent, id, title, size=(450, 400))panel = wx.Panel(self, -1)vbox = wx.BoxSizer(wx.VERTICAL)hbox = wx.BoxSizer(wx.HORIZONTAL)leftPanel = wx.Panel(panel, -1)rightPanel = wx.Panel(panel, -1)self.log = wx.TextCtrl(rightPanel, -1, style=wx.TE_MULTILINE)19 de 21 27/04/2008 1:05

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

Saved successfully!

Ooh no, something went wrong!