1999-04-29 23:29:54 -04:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
import wx
|
1999-04-29 23:29:54 -04:00
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
class TestPanel(wx.Panel):
|
1999-04-29 23:29:54 -04:00
|
|
|
def __init__(self, parent, log):
|
2003-12-08 20:23:28 -05:00
|
|
|
wx.Panel.__init__(self, parent, -1)
|
1999-04-29 23:29:54 -04:00
|
|
|
self.log = log
|
|
|
|
|
|
|
|
sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
|
|
|
|
'six', 'seven', 'eight', 'nine', 'ten', 'eleven',
|
|
|
|
'twelve', 'thirteen', 'fourteen']
|
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
wx.StaticText(self, -1, "This example uses the wxCheckListBox control.", (45, 15))
|
1999-04-29 23:29:54 -04:00
|
|
|
|
2004-06-14 15:10:20 -04:00
|
|
|
lb = wx.CheckListBox(self, -1, (80, 50), wx.DefaultSize, sampleList)
|
2004-01-12 22:17:17 -05:00
|
|
|
self.Bind(wx.EVT_LISTBOX, self.EvtListBox, lb)
|
2004-08-02 18:09:39 -04:00
|
|
|
self.Bind(wx.EVT_CHECKLISTBOX, self.EvtCheckListBox, lb)
|
1999-04-29 23:29:54 -04:00
|
|
|
lb.SetSelection(0)
|
2002-02-12 16:28:41 -05:00
|
|
|
self.lb = lb
|
|
|
|
|
2003-03-25 01:35:27 -05:00
|
|
|
pos = lb.GetPosition().x + lb.GetSize().width + 25
|
2003-12-08 20:23:28 -05:00
|
|
|
btn = wx.Button(self, -1, "Test SetString", (pos, 50))
|
2004-01-12 22:17:17 -05:00
|
|
|
self.Bind(wx.EVT_BUTTON, self.OnTestButton, btn)
|
1999-04-29 23:29:54 -04:00
|
|
|
|
|
|
|
def EvtListBox(self, event):
|
|
|
|
self.log.WriteText('EvtListBox: %s\n' % event.GetString())
|
|
|
|
|
2004-08-02 18:09:39 -04:00
|
|
|
def EvtCheckListBox(self, event):
|
|
|
|
index = event.GetSelection()
|
|
|
|
label = self.lb.GetString(index)
|
|
|
|
status = 'un'
|
|
|
|
if self.lb.IsChecked(index):
|
|
|
|
status = ''
|
|
|
|
self.log.WriteText('Box %s is %schecked \n' % (label, status))
|
|
|
|
self.lb.SetSelection(index) # so that (un)checking also selects (moves the highlight)
|
|
|
|
|
1999-04-29 23:29:54 -04:00
|
|
|
|
2002-02-12 16:28:41 -05:00
|
|
|
def OnTestButton(self, evt):
|
|
|
|
self.lb.SetString(4, "FUBAR")
|
|
|
|
|
1999-04-29 23:29:54 -04:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def runTest(frame, nb, log):
|
|
|
|
win = TestPanel(nb, log)
|
|
|
|
return win
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2003-07-02 19:13:10 -04:00
|
|
|
overview = """\
|
2003-12-08 20:23:28 -05:00
|
|
|
A checklistbox is like a Listbox, but allows items to be checked or unchecked rather
|
|
|
|
than relying on extended selection (e.g. shift-select) to select multiple items in
|
|
|
|
the list.
|
1999-04-29 23:29:54 -04:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
This class is currently implemented under Windows and GTK.
|
1999-04-29 23:29:54 -04:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
This demo shows the basic CheckListBox and how to use the SetString method to change
|
|
|
|
labels dynamically.
|
|
|
|
"""
|
1999-04-29 23:29:54 -04:00
|
|
|
|
|
|
|
|
2003-07-02 19:13:10 -04:00
|
|
|
if __name__ == '__main__':
|
|
|
|
import sys,os
|
|
|
|
import run
|
2004-03-04 19:06:33 -05:00
|
|
|
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
|
1999-04-29 23:29:54 -04:00
|
|
|
|