]>
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
6 #----------------------------------------------------------------------
9 class TestPanel(wxPanel
):
10 def __init__(self
, parent
, log
):
11 wxPanel
.__init
__(self
, parent
, -1)
14 b
= wxButton(self
, -1, "A real button", (10,10))
16 EVT_BUTTON(self
, b
.GetId(), self
.OnButton
)
17 b
= wxButton(self
, -1, "non-default", (140, 10))
18 EVT_BUTTON(self
, b
.GetId(), self
.OnButton
)
19 #wxTextCtrl(self, -1, "", (10,40))
21 b
= wxGenButton(self
, -1, 'Hello', (10,65))
22 EVT_BUTTON(self
, b
.GetId(), self
.OnButton
)
23 b
= wxGenButton(self
, -1, 'disabled', (140,65))
24 EVT_BUTTON(self
, b
.GetId(), self
.OnButton
)
27 b
= wxGenButton(self
, -1, 'bigger', (250,50))
28 EVT_BUTTON(self
, b
.GetId(), self
.OnButton
)
29 b
.SetFont(wxFont(20, wxSWISS
, wxNORMAL
, wxBOLD
, false
))
32 b
.SetBackgroundColour(wxNamedColour("Navy"))
33 b
.SetForegroundColour(wxWHITE
)
34 #b.SetUseFocusIndicator(false)
35 b
.SetToolTipString("This is a BIG button...")
37 bmp
= wxBitmap('bitmaps/test2.bmp', wxBITMAP_TYPE_BMP
)
38 b
= wxGenBitmapButton(self
, -1, bmp
, (10, 130))
39 EVT_BUTTON(self
, b
.GetId(), self
.OnButton
)
42 b
= wxGenBitmapButton(self
, -1, None, (140, 130))
43 EVT_BUTTON(self
, b
.GetId(), self
.OnButton
)
44 bmp
= wxBitmap('bitmaps/lb1.bmp', wxBITMAP_TYPE_BMP
)
45 mask
= wxMaskColour(bmp
, wxBLUE
)
48 bmp
= wxBitmap('bitmaps/lb2.bmp', wxBITMAP_TYPE_BMP
)
49 mask
= wxMaskColour(bmp
, wxBLUE
)
51 b
.SetBitmapSelected(bmp
)
54 b
= wxGenToggleButton(self
, -1, "Toggle Button", (10, 230))
55 EVT_BUTTON(self
, b
.GetId(), self
.OnToggleButton
)
58 b
= wxGenBitmapToggleButton(self
, -1, None, (140, 230))
59 EVT_BUTTON(self
, b
.GetId(), self
.OnToggleButton
)
60 bmp
= wxBitmap('bitmaps/lb1.bmp', wxBITMAP_TYPE_BMP
)
61 mask
= wxMaskColour(bmp
, wxBLUE
)
64 bmp
= wxBitmap('bitmaps/lb2.bmp', wxBITMAP_TYPE_BMP
)
65 mask
= wxMaskColour(bmp
, wxBLUE
)
67 b
.SetBitmapSelected(bmp
)
72 def OnButton(self
, event
):
73 self
.log
.WriteText("Button Clicked: %d\n" % event
.GetId())
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
))
81 #----------------------------------------------------------------------
84 def runTest(frame
, nb
, log
):
85 win
= TestPanel(nb
, log
)
89 #----------------------------------------------------------------------
92 import wxPython
.lib
.buttons
93 overview
= wxPython
.lib
.buttons
.__doc
__