]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/AlphaDrawing.py
Include "xrc" support properly for OpenVMS
[wxWidgets.git] / wxPython / demo / AlphaDrawing.py
CommitLineData
59780c72
RD
1
2import wx
3
4#----------------------------------------------------------------------
5
6class TestPanel(wx.Panel):
7 def __init__(self, parent, log):
8 self.log = log
9 wx.Panel.__init__(self, parent, -1)
59780c72
RD
10 self.Bind(wx.EVT_PAINT, self.OnPaint)
11
2f72b58a
RD
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))
19
20
59780c72
RD
21 def OnPaint(self, evt):
22 dc = wx.PaintDC(self)
23 rect = wx.Rect(0,0, 100, 100)
2f72b58a
RD
24 for RGB, pos in [((178, 34, 34), ( 50, 90)),
25 (( 35, 142, 35), (110, 150)),
26 (( 0, 0, 139), (170, 90))
59780c72
RD
27 ]:
28 r, g, b = RGB
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))
33 rect.SetPosition(pos)
d1a7e73e 34 dc.DrawRoundedRectangleRect(rect, 8)
59780c72
RD
35
36
37#----------------------------------------------------------------------
38
39def runTest(frame, nb, log):
40 win = TestPanel(nb, log)
41 return win
42
43#----------------------------------------------------------------------
44
45
46
47overview = """<html><body>
48<h2><center>Alpha Drawing</center></h2>
49
50The wx.DC on Mac now supports alpha transparent drawing using pens and
51brushes. This is accomplished by enabling the wx.Colour class to have
52a fourth component for the alpha value, where 0 is fully transparent,
53and 255 is fully opaque.
54
2f72b58a
RD
55<p>You can consider this a \"preview of coming attractions\" for the
56other platforms.
57
59780c72
RD
58</body></html>
59"""
60
61
62
63if __name__ == '__main__':
64 import sys,os
65 import run
66 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
67