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