]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/GenericButtons.py
Added possibility of 2-step initialisation, and wxWIZARD_EX_HELPBUTTON style.
[wxWidgets.git] / wxPython / demo / GenericButtons.py
1
2 from wxPython.wx import *
3 from wxPython.lib.buttons import wxGenButton, wxGenBitmapButton, \
4 wxGenToggleButton, wxGenBitmapToggleButton
5
6 import images
7 #----------------------------------------------------------------------
8
9
10 class 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)
18 b = wxButton(self, -1, "non-default", (140, 10))
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)
24 b = wxGenButton(self, -1, 'disabled', (140,65))
25 EVT_BUTTON(self, b.GetId(), self.OnButton)
26 b.Enable(false)
27
28 b = wxGenButton(self, -1, 'bigger', (250,50))
29 EVT_BUTTON(self, b.GetId(), self.OnButton)
30 b.SetFont(wxFont(20, wxSWISS, wxNORMAL, wxBOLD, false))
31 b.SetBezelWidth(5)
32 b.SetBestSize()
33 b.SetBackgroundColour(wxNamedColour("Navy"))
34 b.SetForegroundColour(wxWHITE)
35 #b.SetUseFocusIndicator(false)
36 b.SetToolTipString("This is a BIG button...")
37
38 bmp = images.getTest2Bitmap()
39 b = wxGenBitmapButton(self, -1, bmp, (10, 130))
40 EVT_BUTTON(self, b.GetId(), self.OnButton)
41
42
43 b = wxGenBitmapButton(self, -1, None, (140, 130))
44 EVT_BUTTON(self, b.GetId(), self.OnButton)
45 bmp = images.getBulb1Bitmap()
46 mask = wxMaskColour(bmp, wxBLUE)
47 bmp.SetMask(mask)
48 b.SetBitmapLabel(bmp)
49 bmp = images.getBulb2Bitmap()
50 mask = wxMaskColour(bmp, wxBLUE)
51 bmp.SetMask(mask)
52 b.SetBitmapSelected(bmp)
53 b.SetBestSize()
54
55 b = wxGenToggleButton(self, -1, "Toggle Button", (10, 230))
56 EVT_BUTTON(self, b.GetId(), self.OnToggleButton)
57
58
59 b = wxGenBitmapToggleButton(self, -1, None, (140, 230))
60 EVT_BUTTON(self, b.GetId(), self.OnToggleButton)
61 bmp = images.getBulb1Bitmap()
62 mask = wxMaskColour(bmp, wxBLUE)
63 bmp.SetMask(mask)
64 b.SetBitmapLabel(bmp)
65 bmp = images.getBulb2Bitmap()
66 mask = wxMaskColour(bmp, wxBLUE)
67 bmp.SetMask(mask)
68 b.SetBitmapSelected(bmp)
69 b.SetToggle(true)
70 b.SetBestSize()
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
85 def runTest(frame, nb, log):
86 win = TestPanel(nb, log)
87 return win
88
89
90 #----------------------------------------------------------------------
91
92
93 import wxPython.lib.buttons
94 overview = wxPython.lib.buttons.__doc__