]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/AlphaDrawing.py
   4 #---------------------------------------------------------------------- 
   6 class TestPanel(wx
.Panel
): 
   7     def __init__(self
, parent
, log
): 
   9         wx
.Panel
.__init
__(self
, parent
, -1) 
  10         self
.Bind(wx
.EVT_PAINT
, self
.OnPaint
) 
  12         txt 
= "On the Mac these squares should be transparent, if the\n" \
 
  13               "CoreGraphics option is turned on.  " 
  14         if "wxMac" in wx
.PlatformInfo
: 
  15             txt 
+= "This build of wxPython\n" \
 
  16                    "%s have the CoreGraphics option turned on." \
 
  17                    % ("mac-cg" in wx
.PlatformInfo 
and "DOES" or "DOS NOT") 
  18         wx
.StaticText(self
, -1, txt
, (20, 20)) 
  21     def OnPaint(self
, evt
): 
  23         rect 
= wx
.Rect(0,0, 100, 100) 
  24         for RGB
, pos 
in [((178,  34,  34), ( 50,  90)), 
  25                          (( 35, 142,  35), (110, 150)), 
  26                          ((  0,   0, 139), (170,  90)) 
  29             penclr   
= wx
.Colour(r
, g
, b
, wx
.ALPHA_OPAQUE
) 
  30             brushclr 
= wx
.Colour(r
, g
, b
, 128)   # half transparent 
  31             dc
.SetPen(wx
.Pen(penclr
)) 
  32             dc
.SetBrush(wx
.Brush(brushclr
)) 
  34             dc
.DrawRoundedRectangleRect(rect
, 8) 
  37 #---------------------------------------------------------------------- 
  39 def runTest(frame
, nb
, log
): 
  40     win 
= TestPanel(nb
, log
) 
  43 #---------------------------------------------------------------------- 
  47 overview 
= """<html><body> 
  48 <h2><center>Alpha Drawing</center></h2> 
  50 The wx.DC on Mac now supports alpha transparent drawing using pens and 
  51 brushes.  This is accomplished by enabling the wx.Colour class to have 
  52 a fourth component for the alpha value, where 0 is fully transparent, 
  53 and 255 is fully opaque. 
  55 <p>You can consider this a \"preview of coming attractions\" for the 
  63 if __name__ 
== '__main__': 
  66     run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])