5 #----------------------------------------------------------------------
7 class TestPanel(wx
.Panel
):
8 def __init__(self
, parent
, log
):
9 wx
.Panel
.__init
__(self
, parent
, -1,
10 style
=wx
.NO_FULL_REPAINT_ON_RESIZE
)
13 if 0: # a test case for catching wx.PyAssertionError
15 #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_SUPPRESS)
16 #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_EXCEPTION)
17 #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_DIALOG)
18 #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_EXCEPTION | wx.PYAPP_ASSERT_DIALOG)
21 bmp
= wx
.Bitmap("nosuchfile.bmp", wx
.BITMAP_TYPE_BMP
)
22 mask
= wx
.MaskColour(bmp
, wx
.BLUE
)
23 except wx
.PyAssertionError
:
24 self
.log
.write("Caught wx.PyAssertionError! I will fix the problem.\n")
25 bmp
= images
.getTest2Bitmap()
26 mask
= wx
.MaskColour(bmp
, wx
.BLUE
)
28 bmp
= images
.getTest2Bitmap()
29 mask
= wx
.MaskColour(bmp
, wx
.BLUE
)
32 b
= wx
.BitmapButton(self
, 30, bmp
, (20, 20),
33 (bmp
.GetWidth()+10, bmp
.GetHeight()+10))
34 b
.SetToolTipString("This is a bitmap button.")
35 self
.Bind(wx
.EVT_BUTTON
, self
.OnClick
, b
)
38 def OnClick(self
, event
):
39 self
.log
.write("Click! (%d)\n" % event
.GetId())
42 #----------------------------------------------------------------------
44 def runTest(frame
, nb
, log
):
45 win
= TestPanel(nb
, log
)
48 #----------------------------------------------------------------------
51 overview
= """<html><body>
54 <p>A BitmapButton control displays a bitmap. It can have a separate bitmap for each button state: normal, selected, disabled.</p>
56 <p>The bitmaps to be displayed should have a small number of colours, such as 16,
57 to avoid palette problems.</p>
59 <p>A bitmap can be derived from most image formats using the wx.Image class.</p>
66 if __name__
== '__main__':
69 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])