1999-04-30 03:29:54 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
import wx
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
class TestPanel(wx.Panel):
|
1999-04-30 03:29:54 +00:00
|
|
|
def __init__(self, parent, log):
|
2003-12-09 01:23:28 +00:00
|
|
|
wx.Panel.__init__(self, parent, -1)
|
1999-04-30 03:29:54 +00:00
|
|
|
self.log = log
|
|
|
|
|
|
|
|
sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
|
|
|
|
'six', 'seven', 'eight', 'nine', 'ten', 'eleven',
|
|
|
|
'twelve', 'thirteen', 'fourteen']
|
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
wx.StaticText(self, -1, "This example uses the wxCheckListBox control.", (45, 15))
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2004-06-14 19:10:20 +00:00
|
|
|
lb = wx.CheckListBox(self, -1, (80, 50), wx.DefaultSize, sampleList)
|
2004-01-13 03:17:17 +00:00
|
|
|
self.Bind(wx.EVT_LISTBOX, self.EvtListBox, lb)
|
2004-08-02 22:09:39 +00:00
|
|
|
self.Bind(wx.EVT_CHECKLISTBOX, self.EvtCheckListBox, lb)
|
1999-04-30 03:29:54 +00:00
|
|
|
lb.SetSelection(0)
|
2002-02-12 21:28:41 +00:00
|
|
|
self.lb = lb
|
|
|
|
|
2006-03-10 00:30:28 +00:00
|
|
|
lb.Bind(wx.EVT_RIGHT_DOWN, self.OnDoHitTest)
|
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
pos = lb.GetPosition().x + lb.GetSize().width + 25
|
2003-12-09 01:23:28 +00:00
|
|
|
btn = wx.Button(self, -1, "Test SetString", (pos, 50))
|
2004-01-13 03:17:17 +00:00
|
|
|
self.Bind(wx.EVT_BUTTON, self.OnTestButton, btn)
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
def EvtListBox(self, event):
|
|
|
|
self.log.WriteText('EvtListBox: %s\n' % event.GetString())
|
|
|
|
|
2004-08-02 22:09:39 +00: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-30 03:29:54 +00:00
|
|
|
|
2002-02-12 21:28:41 +00:00
|
|
|
def OnTestButton(self, evt):
|
|
|
|
self.lb.SetString(4, "FUBAR")
|
|
|
|
|
2006-03-10 00:30:28 +00:00
|
|
|
def OnDoHitTest(self, evt):
|
|
|
|
item = self.lb.HitTest(evt.GetPosition())
|
|
|
|
self.log.write("HitTest: %d\n" % item)
|
|
|
|
|
1999-04-30 03:29:54 +00:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def runTest(frame, nb, log):
|
|
|
|
win = TestPanel(nb, log)
|
|
|
|
return win
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2003-07-02 23:13:10 +00:00
|
|
|
overview = """\
|
2003-12-09 01:23:28 +00: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-30 03:29:54 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
This class is currently implemented under Windows and GTK.
|
1999-04-30 03:29:54 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
This demo shows the basic CheckListBox and how to use the SetString method to change
|
|
|
|
labels dynamically.
|
|
|
|
"""
|
1999-04-30 03:29:54 +00:00
|
|
|
|
|
|
|
|
2003-07-02 23:13:10 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
import sys,os
|
|
|
|
import run
|
2004-03-05 00:06:33 +00:00
|
|
|
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
|
1999-04-30 03:29:54 +00:00
|
|
|
|