]>
Commit | Line | Data |
---|---|---|
6999b0d8 RD |
1 | |
2 | from wxPython.wx import * | |
3 | from wxPython.lib.buttons import wxGenButton, wxGenBitmapButton, \ | |
4 | wxGenToggleButton, wxGenBitmapToggleButton | |
5 | ||
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", (100, 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', (100,65)) | |
24 | EVT_BUTTON(self, b.GetId(), self.OnButton) | |
25 | b.Enable(false) | |
26 | ||
78385733 | 27 | b = wxGenButton(self, -1, 'bigger', (195,50)) |
6999b0d8 RD |
28 | EVT_BUTTON(self, b.GetId(), self.OnButton) |
29 | b.SetFont(wxFont(20, wxSWISS, wxNORMAL, wxBOLD, false)) | |
30 | b.SetBezelWidth(5) | |
78385733 RD |
31 | b.SetBestSize() |
32 | b.SetBackgroundColour(wxNamedColour("Navy")) | |
6999b0d8 RD |
33 | b.SetForegroundColour(wxWHITE) |
34 | #b.SetUseFocusIndicator(false) | |
35 | ||
36 | bmp = wxBitmap('bitmaps/test2.bmp', wxBITMAP_TYPE_BMP) | |
78385733 | 37 | b = wxGenBitmapButton(self, -1, bmp, (10, 130)) |
6999b0d8 RD |
38 | EVT_BUTTON(self, b.GetId(), self.OnButton) |
39 | ||
40 | ||
78385733 | 41 | b = wxGenBitmapButton(self, -1, None, (100, 130)) |
6999b0d8 RD |
42 | EVT_BUTTON(self, b.GetId(), self.OnButton) |
43 | bmp = wxBitmap('bitmaps/lb1.bmp', wxBITMAP_TYPE_BMP) | |
5bff6bb8 RD |
44 | if wxPlatform == '__WXMSW__': |
45 | mask = wxMaskColour(bmp, wxBLUE) | |
46 | bmp.SetMask(mask) | |
6999b0d8 RD |
47 | b.SetBitmapLabel(bmp) |
48 | bmp = wxBitmap('bitmaps/lb2.bmp', wxBITMAP_TYPE_BMP) | |
5bff6bb8 RD |
49 | if wxPlatform == '__WXMSW__': |
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 | ||
78385733 | 59 | b = wxGenBitmapToggleButton(self, -1, None, (100, 230)) |
6999b0d8 RD |
60 | EVT_BUTTON(self, b.GetId(), self.OnToggleButton) |
61 | bmp = wxBitmap('bitmaps/lb1.bmp', wxBITMAP_TYPE_BMP) | |
5bff6bb8 RD |
62 | if wxPlatform == '__WXMSW__': |
63 | mask = wxMaskColour(bmp, wxBLUE) | |
64 | bmp.SetMask(mask) | |
6999b0d8 RD |
65 | b.SetBitmapLabel(bmp) |
66 | bmp = wxBitmap('bitmaps/lb2.bmp', wxBITMAP_TYPE_BMP) | |
5bff6bb8 RD |
67 | if wxPlatform == '__WXMSW__': |
68 | mask = wxMaskColour(bmp, wxBLUE) | |
69 | bmp.SetMask(mask) | |
6999b0d8 | 70 | b.SetBitmapSelected(bmp) |
fbff5d1b | 71 | b.SetToggle(true) |
78385733 | 72 | b.SetBestSize() |
6999b0d8 RD |
73 | |
74 | ||
75 | def OnButton(self, event): | |
76 | self.log.WriteText("Button Clicked: %d\n" % event.GetId()) | |
77 | ||
78 | def OnToggleButton(self, event): | |
79 | msg = (event.GetIsDown() and "on") or "off" | |
80 | self.log.WriteText("Button %d Toggled: %s\n" % (event.GetId(), msg)) | |
81 | ||
82 | ||
83 | ||
84 | #---------------------------------------------------------------------- | |
85 | ||
86 | ||
87 | def runTest(frame, nb, log): | |
88 | win = TestPanel(nb, log) | |
89 | return win | |
90 | ||
91 | ||
92 | #---------------------------------------------------------------------- | |
93 | ||
94 | ||
95 | import wxPython.lib.buttons | |
96 | overview = wxPython.lib.buttons.__doc__ |