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
.Mask(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
.Mask(bmp
, wx
.BLUE
)
32 b
= wx
.BitmapButton(self
, -1, 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
)
37 b
= wx
.BitmapButton(self
, -1, bmp
, (20, 120),
38 (bmp
.GetWidth()+10, bmp
.GetHeight()+10),
40 b
.SetToolTipString("This is a bitmap button with \nwx.NO_BORDER style.")
41 self
.Bind(wx
.EVT_BUTTON
, self
.OnClick
, b
)
44 def OnClick(self
, event
):
45 self
.log
.write("Click! (%d)\n" % event
.GetId())
48 #----------------------------------------------------------------------
50 def runTest(frame
, nb
, log
):
51 win
= TestPanel(nb
, log
)
54 #----------------------------------------------------------------------
57 overview
= """<html><body>
60 <p>A BitmapButton control displays a bitmap. It can have a separate bitmap for each button state: normal, selected, disabled.</p>
62 <p>The bitmaps to be displayed should have a small number of colours, such as 16,
63 to avoid palette problems.</p>
65 <p>A bitmap can be derived from most image formats using the wx.Image class.</p>
72 if __name__
== '__main__':
75 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])