]> git.saurik.com Git - wxWidgets.git/blame - utils/wxPython/demo/GenericButtons.py
* Added IsPaused() to wxSoundFileStream
[wxWidgets.git] / utils / wxPython / demo / GenericButtons.py
CommitLineData
6999b0d8
RD
1
2from wxPython.wx import *
3from wxPython.lib.buttons import wxGenButton, wxGenBitmapButton, \
4 wxGenToggleButton, wxGenBitmapToggleButton
5
6#----------------------------------------------------------------------
7
8
9class 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)
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
8e425133 41 b = wxGenBitmapButton(self, -1, None, (140, 130))
6999b0d8
RD
42 EVT_BUTTON(self, b.GetId(), self.OnButton)
43 bmp = wxBitmap('bitmaps/lb1.bmp', wxBITMAP_TYPE_BMP)
54b96882
RD
44 mask = wxMaskColour(bmp, wxBLUE)
45 bmp.SetMask(mask)
6999b0d8
RD
46 b.SetBitmapLabel(bmp)
47 bmp = wxBitmap('bitmaps/lb2.bmp', wxBITMAP_TYPE_BMP)
54b96882
RD
48 mask = wxMaskColour(bmp, wxBLUE)
49 bmp.SetMask(mask)
6999b0d8 50 b.SetBitmapSelected(bmp)
78385733 51 b.SetBestSize()
6999b0d8 52
78385733 53 b = wxGenToggleButton(self, -1, "Toggle Button", (10, 230))
6999b0d8
RD
54 EVT_BUTTON(self, b.GetId(), self.OnToggleButton)
55
56
8e425133 57 b = wxGenBitmapToggleButton(self, -1, None, (140, 230))
6999b0d8
RD
58 EVT_BUTTON(self, b.GetId(), self.OnToggleButton)
59 bmp = wxBitmap('bitmaps/lb1.bmp', wxBITMAP_TYPE_BMP)
54b96882
RD
60 mask = wxMaskColour(bmp, wxBLUE)
61 bmp.SetMask(mask)
6999b0d8
RD
62 b.SetBitmapLabel(bmp)
63 bmp = wxBitmap('bitmaps/lb2.bmp', wxBITMAP_TYPE_BMP)
54b96882
RD
64 mask = wxMaskColour(bmp, wxBLUE)
65 bmp.SetMask(mask)
6999b0d8 66 b.SetBitmapSelected(bmp)
fbff5d1b 67 b.SetToggle(true)
78385733 68 b.SetBestSize()
6999b0d8
RD
69
70
71 def OnButton(self, event):
72 self.log.WriteText("Button Clicked: %d\n" % event.GetId())
73
74 def OnToggleButton(self, event):
75 msg = (event.GetIsDown() and "on") or "off"
76 self.log.WriteText("Button %d Toggled: %s\n" % (event.GetId(), msg))
77
78
79
80#----------------------------------------------------------------------
81
82
83def runTest(frame, nb, log):
84 win = TestPanel(nb, log)
85 return win
86
87
88#----------------------------------------------------------------------
89
90
91import wxPython.lib.buttons
92overview = wxPython.lib.buttons.__doc__