]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/GenericButtons.py
2 from wxPython
.wx
import *
3 from wxPython
.lib
.buttons
import wxGenButton
, wxGenBitmapButton
, \
4 wxGenToggleButton
, wxGenBitmapToggleButton
7 #----------------------------------------------------------------------
10 class TestPanel(wxPanel
):
11 def __init__(self
, parent
, log
):
12 wxPanel
.__init
__(self
, parent
, -1)
15 b
= wxButton(self
, -1, "A real button", (10,10))
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))
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
)
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
))
33 b
.SetBackgroundColour(wxNamedColour("Navy"))
34 b
.SetForegroundColour(wxWHITE
)
35 #b.SetUseFocusIndicator(false)
36 b
.SetToolTipString("This is a BIG button...")
38 bmp
= images
.getTest2Bitmap()
39 b
= wxGenBitmapButton(self
, -1, bmp
, (10, 130))
40 EVT_BUTTON(self
, b
.GetId(), self
.OnButton
)
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
)
49 bmp
= images
.getBulb2Bitmap()
50 mask
= wxMaskColour(bmp
, wxBLUE
)
52 b
.SetBitmapSelected(bmp
)
55 b
= wxGenToggleButton(self
, -1, "Toggle Button", (10, 230))
56 EVT_BUTTON(self
, b
.GetId(), self
.OnToggleButton
)
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
)
65 bmp
= images
.getBulb2Bitmap()
66 mask
= wxMaskColour(bmp
, wxBLUE
)
68 b
.SetBitmapSelected(bmp
)
73 def OnButton(self
, event
):
74 self
.log
.WriteText("Button Clicked: %d\n" % event
.GetId())
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
))
82 #----------------------------------------------------------------------
85 def runTest(frame
, nb
, log
):
86 win
= TestPanel(nb
, log
)
90 #----------------------------------------------------------------------
93 import wxPython
.lib
.buttons
94 overview
= wxPython
.lib
.buttons
.__doc
__