2003-12-09 01:23:28 +00:00
|
|
|
# 11/15/2003 - Jeff Grimmett (grimmtooth@softhome.net)
|
|
|
|
#
|
|
|
|
# o Updated for wx namespace
|
|
|
|
# o Why is there a popup menu in this demo?
|
|
|
|
#
|
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
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
lb = wx.CheckListBox(self, 60, (80, 50), (80, 120), sampleList)
|
|
|
|
self.Bind(wx.EVT_LISTBOX, self.EvtListBox, id=60)
|
|
|
|
self.Bind(wx.EVT_LISTBOX_DCLICK, self.EvtListBoxDClick, id=60)
|
1999-04-30 03:29:54 +00:00
|
|
|
lb.SetSelection(0)
|
2002-02-12 21:28:41 +00:00
|
|
|
self.lb = lb
|
|
|
|
|
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))
|
|
|
|
self.Bind(wx.EVT_BUTTON, self.OnTestButton, id=btn.GetId())
|
|
|
|
self.Bind(wx.EVT_RIGHT_UP, self.OnDoPopup)
|
1999-04-30 03:29:54 +00: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 21:28:41 +00:00
|
|
|
def OnTestButton(self, evt):
|
|
|
|
self.lb.SetString(4, "FUBAR")
|
|
|
|
|
|
|
|
|
2001-05-22 05:59:09 +00:00
|
|
|
def OnDoPopup(self, evt):
|
2003-12-09 01:23:28 +00:00
|
|
|
menu = wx.Menu()
|
2001-05-22 05:59:09 +00:00
|
|
|
# Make this first item bold
|
2003-12-09 01:23:28 +00: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 05:59:09 +00:00
|
|
|
item.SetFont(nf)
|
|
|
|
menu.AppendItem(item)
|
|
|
|
|
2003-12-09 01:23:28 +00: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 05:59:09 +00:00
|
|
|
|
|
|
|
self.PopupMenu(menu, evt.GetPosition())
|
|
|
|
menu.Destroy()
|
|
|
|
evt.Skip()
|
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
|
|
|
|
run.main(['', os.path.basename(sys.argv[0])])
|
1999-04-30 03:29:54 +00:00
|
|
|
|