]>
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) | |
8e425133 | 17 | b = wxButton(self, -1, "non-default", (140, 10)) |
6999b0d8 RD |
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) | |
8e425133 | 23 | b = wxGenButton(self, -1, 'disabled', (140,65)) |
6999b0d8 RD |
24 | EVT_BUTTON(self, b.GetId(), self.OnButton) |
25 | b.Enable(false) | |
26 | ||
8e425133 | 27 | b = wxGenButton(self, -1, 'bigger', (250,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) | |
185d7c3e | 35 | b.SetToolTipString("This is a BIG button...") |
6999b0d8 RD |
36 | |
37 | bmp = wxBitmap('bitmaps/test2.bmp', wxBITMAP_TYPE_BMP) | |
78385733 | 38 | b = wxGenBitmapButton(self, -1, bmp, (10, 130)) |
6999b0d8 RD |
39 | EVT_BUTTON(self, b.GetId(), self.OnButton) |
40 | ||
41 | ||
8e425133 | 42 | b = wxGenBitmapButton(self, -1, None, (140, 130)) |
6999b0d8 RD |
43 | EVT_BUTTON(self, b.GetId(), self.OnButton) |
44 | bmp = wxBitmap('bitmaps/lb1.bmp', wxBITMAP_TYPE_BMP) | |
54b96882 RD |
45 | mask = wxMaskColour(bmp, wxBLUE) |
46 | bmp.SetMask(mask) | |
6999b0d8 RD |
47 | b.SetBitmapLabel(bmp) |
48 | bmp = wxBitmap('bitmaps/lb2.bmp', wxBITMAP_TYPE_BMP) | |
54b96882 RD |
49 | mask = wxMaskColour(bmp, wxBLUE) |
50 | bmp.SetMask(mask) | |
6999b0d8 | 51 | b.SetBitmapSelected(bmp) |
78385733 | 52 | b.SetBestSize() |
6999b0d8 | 53 | |
78385733 | 54 | b = wxGenToggleButton(self, -1, "Toggle Button", (10, 230)) |
6999b0d8 RD |
55 | EVT_BUTTON(self, b.GetId(), self.OnToggleButton) |
56 | ||
57 | ||
8e425133 | 58 | b = wxGenBitmapToggleButton(self, -1, None, (140, 230)) |
6999b0d8 RD |
59 | EVT_BUTTON(self, b.GetId(), self.OnToggleButton) |
60 | bmp = wxBitmap('bitmaps/lb1.bmp', wxBITMAP_TYPE_BMP) | |
54b96882 RD |
61 | mask = wxMaskColour(bmp, wxBLUE) |
62 | bmp.SetMask(mask) | |
6999b0d8 RD |
63 | b.SetBitmapLabel(bmp) |
64 | bmp = wxBitmap('bitmaps/lb2.bmp', wxBITMAP_TYPE_BMP) | |
54b96882 RD |
65 | mask = wxMaskColour(bmp, wxBLUE) |
66 | bmp.SetMask(mask) | |
6999b0d8 | 67 | b.SetBitmapSelected(bmp) |
fbff5d1b | 68 | b.SetToggle(true) |
78385733 | 69 | b.SetBestSize() |
6999b0d8 RD |
70 | |
71 | ||
72 | def OnButton(self, event): | |
73 | self.log.WriteText("Button Clicked: %d\n" % event.GetId()) | |
74 | ||
75 | def OnToggleButton(self, event): | |
76 | msg = (event.GetIsDown() and "on") or "off" | |
77 | self.log.WriteText("Button %d Toggled: %s\n" % (event.GetId(), msg)) | |
78 | ||
79 | ||
80 | ||
81 | #---------------------------------------------------------------------- | |
82 | ||
83 | ||
84 | def runTest(frame, nb, log): | |
85 | win = TestPanel(nb, log) | |
86 | return win | |
87 | ||
88 | ||
89 | #---------------------------------------------------------------------- | |
90 | ||
91 | ||
92 | import wxPython.lib.buttons | |
93 | overview = wxPython.lib.buttons.__doc__ |