]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/ImageAlpha.py
   2 import wx                  
# This module uses the new wx namespace 
   6 #---------------------------------------------------------------------- 
   8 msg 
= "This is some text that will appear behind the image..." 
  10 class TestPanel(wx
.Panel
): 
  11     def __init__(self
, parent
, log
): 
  13         wx
.Panel
.__init
__(self
, parent
, -1) 
  15         self
.Bind(wx
.EVT_PAINT
, self
.OnPaint
) 
  18     def OnPaint(self
, evt
): 
  20         dc
.SetBackground(wx
.Brush("WHITE")) 
  23         dc
.SetFont(wx
.Font(16, wx
.SWISS
, wx
.NORMAL
, wx
.BOLD
, True)) 
  24         dc
.DrawText("Bitmap alpha blending (on wxMSW and wxMac only)", 
  27         bmp 
= wx
.Bitmap(opj('bitmaps/toucan.png')) 
  28         if "__WXGTK__" in wx
.PlatformInfo
: 
  29             # try to make up for it a bit... 
  30             bmp
.SetMaskColour("black") 
  32         dc
.DrawBitmap(bmp
, (25,100), True) 
  34         dc
.SetFont(self
.GetFont()) 
  36         for line 
in range(10): 
  37             y 
+= dc
.GetCharHeight() + 5 
  38             dc
.DrawText(msg
, (200, y
)) 
  39         dc
.DrawBitmap(bmp
, (250,100), True) 
  43 #---------------------------------------------------------------------- 
  45 def runTest(frame
, nb
, log
): 
  46     win 
= TestPanel(nb
, log
) 
  49 #---------------------------------------------------------------------- 
  53 overview 
= """<html><body> 
  54 <h2><center>Images with Alpha</center></h2> 
  56 wxMSW and wxMac now support alpha channels of supported image 
  57 types, and will properly blend that channel when drawing a 
  58 bitmap.  It is not supported yet on wxGTK, (if you would like to 
  59 change that please submit a patch!) 
  61 <p>On wxGTK this demo turns the alpha channel into a 1-bit mask, so 
  62 yes, it looks like crap.  Please help us fix it! 
  69 if __name__ 
== '__main__': 
  72     run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])