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-01-12 22:17:17 -05:00
|
|
|
lb = wx.CheckListBox(self, -1, (80, 50), (80, 120), sampleList)
|
|
|
|
self.Bind(wx.EVT_LISTBOX, self.EvtListBox, lb)
|
|
|
|
self.Bind(wx.EVT_LISTBOX_DCLICK, self.EvtListBoxDClick, 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)
|
2003-12-08 20:23:28 -05:00
|
|
|
self.Bind(wx.EVT_RIGHT_UP, self.OnDoPopup)
|
1999-04-29 23:29:54 -04:00
|
|
|
|
|
|
|
def EvtListBox(self, event):
|
|
|
|
self.log.WriteText('EvtListBox: %s\n' % event.GetString())
|
|
|
|
|
|
|
|
def EvtListBoxDClick(self, event):
|
|
|
|
self.log.WriteText('EvtListBoxDClick:\n')
|
|
|
|
|
2002-02-12 16:28:41 -05:00
|
|
|
def OnTestButton(self, evt):
|
|
|
|
self.lb.SetString(4, "FUBAR")
|
|
|
|
|
|
|
|
|
2001-05-22 01:59:09 -04:00
|
|
|
def OnDoPopup(self, evt):
|
2003-12-08 20:23:28 -05:00
|
|
|
menu = wx.Menu()
|
2001-05-22 01:59:09 -04:00
|
|
|
# Make this first item bold
|
2003-12-08 20:23:28 -05:00
|
|
|
item = wx.MenuItem(menu, wx.NewId(), "If supported, this is bold")
|
|
|
|
df = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
|
|
|
|
|
|
|
|
nf = wx.Font(
|
|
|
|
df.GetPointSize(), df.GetFamily(), df.GetStyle(),
|
|
|
|
wx.BOLD, False, df.GetFaceName()
|
|
|
|
)
|
|
|
|
|
2001-05-22 01:59:09 -04:00
|
|
|
item.SetFont(nf)
|
|
|
|
menu.AppendItem(item)
|
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
menu.AppendItem(wx.MenuItem(menu, wx.NewId(), "Normal Item &1"))
|
|
|
|
menu.AppendItem(wx.MenuItem(menu, wx.NewId(), "Normal Item &2"))
|
|
|
|
menu.AppendItem(wx.MenuItem(menu, wx.NewId(), "Normal Item &3"))
|
|
|
|
menu.AppendItem(wx.MenuItem(menu, wx.NewId(), "Normal Item &4"))
|
2001-05-22 01:59:09 -04:00
|
|
|
|
|
|
|
self.PopupMenu(menu, evt.GetPosition())
|
|
|
|
menu.Destroy()
|
|
|
|
evt.Skip()
|
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
|
|
|
|
run.main(['', os.path.basename(sys.argv[0])])
|
1999-04-29 23:29:54 -04:00
|
|
|
|