]>
git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/demo/GenericButtons.py
726874eea08d9400686272329d0da077a61a2796
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", (100, 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', (100,65))
24 EVT_BUTTON(self
, b
.GetId(), self
.OnButton
)
27 b
= wxGenButton(self
, -1, 'bigger', (195,50), (120, 55))
28 EVT_BUTTON(self
, b
.GetId(), self
.OnButton
)
29 b
.SetFont(wxFont(20, wxSWISS
, wxNORMAL
, wxBOLD
, false
))
31 b
.SetBackgroundColour(wxBLUE
)
32 b
.SetForegroundColour(wxWHITE
)
33 #b.SetUseFocusIndicator(false)
35 bmp
= wxBitmap('bitmaps/test2.bmp', wxBITMAP_TYPE_BMP
)
36 b
= wxGenBitmapButton(self
, -1, bmp
, (10, 130),
37 (bmp
.GetWidth()+16, bmp
.GetHeight()+16))
38 EVT_BUTTON(self
, b
.GetId(), self
.OnButton
)
41 b
= wxGenBitmapButton(self
, -1, None, (100, 130), (48,48))
42 EVT_BUTTON(self
, b
.GetId(), self
.OnButton
)
43 bmp
= wxBitmap('bitmaps/lb1.bmp', wxBITMAP_TYPE_BMP
)
44 mask
= wxMaskColour(bmp
, wxBLUE
)
47 bmp
= wxBitmap('bitmaps/lb2.bmp', wxBITMAP_TYPE_BMP
)
48 mask
= wxMaskColour(bmp
, wxBLUE
)
50 b
.SetBitmapSelected(bmp
)
53 b
= wxGenToggleButton(self
, -1, "Toggle Button", (10, 230), (85, 26))
54 EVT_BUTTON(self
, b
.GetId(), self
.OnToggleButton
)
57 b
= wxGenBitmapToggleButton(self
, -1, None, (100, 230), (48,48))
58 EVT_BUTTON(self
, b
.GetId(), self
.OnToggleButton
)
59 bmp
= wxBitmap('bitmaps/lb1.bmp', wxBITMAP_TYPE_BMP
)
60 mask
= wxMaskColour(bmp
, wxBLUE
)
63 bmp
= wxBitmap('bitmaps/lb2.bmp', wxBITMAP_TYPE_BMP
)
64 mask
= wxMaskColour(bmp
, wxBLUE
)
66 b
.SetBitmapSelected(bmp
)
70 def OnButton(self
, event
):
71 self
.log
.WriteText("Button Clicked: %d\n" % event
.GetId())
73 def OnToggleButton(self
, event
):
74 msg
= (event
.GetIsDown() and "on") or "off"
75 self
.log
.WriteText("Button %d Toggled: %s\n" % (event
.GetId(), msg
))
79 #----------------------------------------------------------------------
82 def runTest(frame
, nb
, log
):
83 win
= TestPanel(nb
, log
)
87 #----------------------------------------------------------------------
90 import wxPython
.lib
.buttons
91 overview
= wxPython
.lib
.buttons
.__doc
__