1999-12-11 07:59:23 +00:00
|
|
|
|
|
|
|
from wxPython.wx import *
|
2001-09-03 23:23:47 +00:00
|
|
|
from wxPython.lib.buttons import *
|
1999-12-11 07:59:23 +00:00
|
|
|
|
2001-04-09 19:36:36 +00:00
|
|
|
import images
|
1999-12-11 07:59:23 +00:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
class TestPanel(wxPanel):
|
|
|
|
def __init__(self, parent, log):
|
|
|
|
wxPanel.__init__(self, parent, -1)
|
|
|
|
self.log = log
|
|
|
|
|
|
|
|
b = wxButton(self, -1, "A real button", (10,10))
|
|
|
|
b.SetDefault()
|
|
|
|
EVT_BUTTON(self, b.GetId(), self.OnButton)
|
2000-01-19 06:58:56 +00:00
|
|
|
b = wxButton(self, -1, "non-default", (140, 10))
|
1999-12-11 07:59:23 +00:00
|
|
|
EVT_BUTTON(self, b.GetId(), self.OnButton)
|
|
|
|
#wxTextCtrl(self, -1, "", (10,40))
|
|
|
|
|
|
|
|
b = wxGenButton(self, -1, 'Hello', (10,65))
|
|
|
|
EVT_BUTTON(self, b.GetId(), self.OnButton)
|
2000-01-19 06:58:56 +00:00
|
|
|
b = wxGenButton(self, -1, 'disabled', (140,65))
|
1999-12-11 07:59:23 +00:00
|
|
|
EVT_BUTTON(self, b.GetId(), self.OnButton)
|
|
|
|
b.Enable(false)
|
|
|
|
|
2000-01-19 06:58:56 +00:00
|
|
|
b = wxGenButton(self, -1, 'bigger', (250,50))
|
1999-12-11 07:59:23 +00:00
|
|
|
EVT_BUTTON(self, b.GetId(), self.OnButton)
|
|
|
|
b.SetFont(wxFont(20, wxSWISS, wxNORMAL, wxBOLD, false))
|
|
|
|
b.SetBezelWidth(5)
|
1999-12-14 06:38:17 +00:00
|
|
|
b.SetBestSize()
|
|
|
|
b.SetBackgroundColour(wxNamedColour("Navy"))
|
1999-12-11 07:59:23 +00:00
|
|
|
b.SetForegroundColour(wxWHITE)
|
|
|
|
#b.SetUseFocusIndicator(false)
|
2000-11-21 03:44:14 +00:00
|
|
|
b.SetToolTipString("This is a BIG button...")
|
1999-12-11 07:59:23 +00:00
|
|
|
|
2001-04-09 19:36:36 +00:00
|
|
|
bmp = images.getTest2Bitmap()
|
1999-12-14 06:38:17 +00:00
|
|
|
b = wxGenBitmapButton(self, -1, bmp, (10, 130))
|
1999-12-11 07:59:23 +00:00
|
|
|
EVT_BUTTON(self, b.GetId(), self.OnButton)
|
|
|
|
|
|
|
|
|
2000-01-19 06:58:56 +00:00
|
|
|
b = wxGenBitmapButton(self, -1, None, (140, 130))
|
1999-12-11 07:59:23 +00:00
|
|
|
EVT_BUTTON(self, b.GetId(), self.OnButton)
|
2001-04-09 19:36:36 +00:00
|
|
|
bmp = images.getBulb1Bitmap()
|
1999-12-29 22:10:32 +00:00
|
|
|
mask = wxMaskColour(bmp, wxBLUE)
|
|
|
|
bmp.SetMask(mask)
|
1999-12-11 07:59:23 +00:00
|
|
|
b.SetBitmapLabel(bmp)
|
2001-04-09 19:36:36 +00:00
|
|
|
bmp = images.getBulb2Bitmap()
|
1999-12-29 22:10:32 +00:00
|
|
|
mask = wxMaskColour(bmp, wxBLUE)
|
|
|
|
bmp.SetMask(mask)
|
1999-12-11 07:59:23 +00:00
|
|
|
b.SetBitmapSelected(bmp)
|
1999-12-14 06:38:17 +00:00
|
|
|
b.SetBestSize()
|
1999-12-11 07:59:23 +00:00
|
|
|
|
1999-12-14 06:38:17 +00:00
|
|
|
b = wxGenToggleButton(self, -1, "Toggle Button", (10, 230))
|
1999-12-11 07:59:23 +00:00
|
|
|
EVT_BUTTON(self, b.GetId(), self.OnToggleButton)
|
|
|
|
|
|
|
|
|
2000-01-19 06:58:56 +00:00
|
|
|
b = wxGenBitmapToggleButton(self, -1, None, (140, 230))
|
1999-12-11 07:59:23 +00:00
|
|
|
EVT_BUTTON(self, b.GetId(), self.OnToggleButton)
|
2001-04-09 19:36:36 +00:00
|
|
|
bmp = images.getBulb1Bitmap()
|
1999-12-29 22:10:32 +00:00
|
|
|
mask = wxMaskColour(bmp, wxBLUE)
|
|
|
|
bmp.SetMask(mask)
|
1999-12-11 07:59:23 +00:00
|
|
|
b.SetBitmapLabel(bmp)
|
2001-04-09 19:36:36 +00:00
|
|
|
bmp = images.getBulb2Bitmap()
|
1999-12-29 22:10:32 +00:00
|
|
|
mask = wxMaskColour(bmp, wxBLUE)
|
|
|
|
bmp.SetMask(mask)
|
1999-12-11 07:59:23 +00:00
|
|
|
b.SetBitmapSelected(bmp)
|
1999-12-11 08:09:25 +00:00
|
|
|
b.SetToggle(true)
|
1999-12-14 06:38:17 +00:00
|
|
|
b.SetBestSize()
|
1999-12-11 07:59:23 +00:00
|
|
|
|
2001-09-03 23:23:47 +00:00
|
|
|
b = wxGenBitmapTextButton(self, -1, None, "Bitmapped Text", (220, 230), size = (200, 45))
|
|
|
|
EVT_BUTTON(self, b.GetId(), self.OnButton)
|
|
|
|
bmp = images.getBulb1Bitmap()
|
|
|
|
mask = wxMaskColour(bmp, wxBLUE)
|
|
|
|
bmp.SetMask(mask)
|
|
|
|
b.SetBitmapLabel(bmp)
|
|
|
|
bmp = images.getBulb2Bitmap()
|
|
|
|
mask = wxMaskColour(bmp, wxBLUE)
|
|
|
|
bmp.SetMask(mask)
|
|
|
|
b.SetBitmapSelected(bmp)
|
|
|
|
b.SetUseFocusIndicator(false)
|
|
|
|
b.SetBestSize()
|
|
|
|
|
1999-12-11 07:59:23 +00:00
|
|
|
|
|
|
|
def OnButton(self, event):
|
|
|
|
self.log.WriteText("Button Clicked: %d\n" % event.GetId())
|
|
|
|
|
|
|
|
def OnToggleButton(self, event):
|
|
|
|
msg = (event.GetIsDown() and "on") or "off"
|
|
|
|
self.log.WriteText("Button %d Toggled: %s\n" % (event.GetId(), msg))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
def runTest(frame, nb, log):
|
|
|
|
win = TestPanel(nb, log)
|
|
|
|
return win
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
import wxPython.lib.buttons
|
|
|
|
overview = wxPython.lib.buttons.__doc__
|