]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/GenericButtons.py
fixed the last of the off-by-one errors (some are refixed, again...)
[wxWidgets.git] / wxPython / demo / GenericButtons.py
CommitLineData
6999b0d8
RD
1
2from wxPython.wx import *
3from wxPython.lib.buttons import wxGenButton, wxGenBitmapButton, \
4 wxGenToggleButton, wxGenBitmapToggleButton
5
96bfd053 6import images
6999b0d8
RD
7#----------------------------------------------------------------------
8
9
10class TestPanel(wxPanel):
11 def __init__(self, parent, log):
12 wxPanel.__init__(self, parent, -1)
13 self.log = log
14
15 b = wxButton(self, -1, "A real button", (10,10))
16 b.SetDefault()
17 EVT_BUTTON(self, b.GetId(), self.OnButton)
8e425133 18 b = wxButton(self, -1, "non-default", (140, 10))
6999b0d8
RD
19 EVT_BUTTON(self, b.GetId(), self.OnButton)
20 #wxTextCtrl(self, -1, "", (10,40))
21
22 b = wxGenButton(self, -1, 'Hello', (10,65))
23 EVT_BUTTON(self, b.GetId(), self.OnButton)
8e425133 24 b = wxGenButton(self, -1, 'disabled', (140,65))
6999b0d8
RD
25 EVT_BUTTON(self, b.GetId(), self.OnButton)
26 b.Enable(false)
27
8e425133 28 b = wxGenButton(self, -1, 'bigger', (250,50))
6999b0d8
RD
29 EVT_BUTTON(self, b.GetId(), self.OnButton)
30 b.SetFont(wxFont(20, wxSWISS, wxNORMAL, wxBOLD, false))
31 b.SetBezelWidth(5)
78385733
RD
32 b.SetBestSize()
33 b.SetBackgroundColour(wxNamedColour("Navy"))
6999b0d8
RD
34 b.SetForegroundColour(wxWHITE)
35 #b.SetUseFocusIndicator(false)
185d7c3e 36 b.SetToolTipString("This is a BIG button...")
6999b0d8 37
96bfd053 38 bmp = images.getTest2Bitmap()
78385733 39 b = wxGenBitmapButton(self, -1, bmp, (10, 130))
6999b0d8
RD
40 EVT_BUTTON(self, b.GetId(), self.OnButton)
41
42
8e425133 43 b = wxGenBitmapButton(self, -1, None, (140, 130))
6999b0d8 44 EVT_BUTTON(self, b.GetId(), self.OnButton)
96bfd053 45 bmp = images.getBulb1Bitmap()
54b96882
RD
46 mask = wxMaskColour(bmp, wxBLUE)
47 bmp.SetMask(mask)
6999b0d8 48 b.SetBitmapLabel(bmp)
96bfd053 49 bmp = images.getBulb2Bitmap()
54b96882
RD
50 mask = wxMaskColour(bmp, wxBLUE)
51 bmp.SetMask(mask)
6999b0d8 52 b.SetBitmapSelected(bmp)
78385733 53 b.SetBestSize()
6999b0d8 54
78385733 55 b = wxGenToggleButton(self, -1, "Toggle Button", (10, 230))
6999b0d8
RD
56 EVT_BUTTON(self, b.GetId(), self.OnToggleButton)
57
58
8e425133 59 b = wxGenBitmapToggleButton(self, -1, None, (140, 230))
6999b0d8 60 EVT_BUTTON(self, b.GetId(), self.OnToggleButton)
96bfd053 61 bmp = images.getBulb1Bitmap()
54b96882
RD
62 mask = wxMaskColour(bmp, wxBLUE)
63 bmp.SetMask(mask)
6999b0d8 64 b.SetBitmapLabel(bmp)
96bfd053 65 bmp = images.getBulb2Bitmap()
54b96882
RD
66 mask = wxMaskColour(bmp, wxBLUE)
67 bmp.SetMask(mask)
6999b0d8 68 b.SetBitmapSelected(bmp)
fbff5d1b 69 b.SetToggle(true)
78385733 70 b.SetBestSize()
6999b0d8
RD
71
72
73 def OnButton(self, event):
74 self.log.WriteText("Button Clicked: %d\n" % event.GetId())
75
76 def OnToggleButton(self, event):
77 msg = (event.GetIsDown() and "on") or "off"
78 self.log.WriteText("Button %d Toggled: %s\n" % (event.GetId(), msg))
79
80
81
82#----------------------------------------------------------------------
83
84
85def runTest(frame, nb, log):
86 win = TestPanel(nb, log)
87 return win
88
89
90#----------------------------------------------------------------------
91
92
93import wxPython.lib.buttons
94overview = wxPython.lib.buttons.__doc__