6 #wx.BitmapButton = wx.lib.buttons.GenBitmapButton 
   8 #---------------------------------------------------------------------- 
  10 class TestPanel(wx
.Panel
): 
  11     def __init__(self
, parent
, log
): 
  12         wx
.Panel
.__init
__(self
, parent
, -1, 
  13                          style
=wx
.NO_FULL_REPAINT_ON_RESIZE
) 
  16         if 0:  # a test case for catching wx.PyAssertionError 
  18             #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_SUPPRESS) 
  19             #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_EXCEPTION) 
  20             #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_DIALOG) 
  21             #wx.GetApp().SetAssertMode(wx.PYAPP_ASSERT_EXCEPTION | wx.PYAPP_ASSERT_DIALOG) 
  24                 bmp 
= wx
.Bitmap("nosuchfile.bmp", wx
.BITMAP_TYPE_BMP
) 
  25                 mask 
= wx
.Mask(bmp
, wx
.BLUE
) 
  26             except wx
.PyAssertionError
: 
  27                 self
.log
.write("Caught wx.PyAssertionError!  I will fix the problem.\n") 
  28                 bmp 
= images
.getTest2Bitmap() 
  29                 mask 
= wx
.MaskColour(bmp
, wx
.BLUE
) 
  31             bmp 
= images
.getTest2Bitmap() 
  32             mask 
= wx
.Mask(bmp
, wx
.BLUE
) 
  35         b 
= wx
.BitmapButton(self
, -1, bmp
, (20, 20), 
  36                        (bmp
.GetWidth()+10, bmp
.GetHeight()+10)) 
  37         b
.SetToolTipString("This is a bitmap button.") 
  38         self
.Bind(wx
.EVT_BUTTON
, self
.OnClick
, b
) 
  40         b 
= wx
.BitmapButton(self
, -1, bmp
, (20, 120), 
  43         # hide a little surprise in the button... 
  44         b
.SetBitmapSelected(images
.getRobinBitmap()) 
  46         b
.SetToolTipString("This is a bitmap button with \nwx.NO_BORDER style.") 
  47         self
.Bind(wx
.EVT_BUTTON
, self
.OnClick
, b
) 
  50     def OnClick(self
, event
): 
  51         self
.log
.write("Click! (%d)\n" % event
.GetId()) 
  54 #---------------------------------------------------------------------- 
  56 def runTest(frame
, nb
, log
): 
  57     win 
= TestPanel(nb
, log
) 
  60 #---------------------------------------------------------------------- 
  63 overview 
= """<html><body> 
  66 <p>A BitmapButton control displays a bitmap. It can have a separate bitmap for each button state: normal, selected, disabled.</p> 
  68 <p>The bitmaps to be displayed should have a small number of colours, such as 16,  
  69 to avoid palette problems.</p> 
  71 <p>A bitmap can be derived from most image formats using the wx.Image class.</p> 
  78 if __name__ 
== '__main__': 
  81     run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])