]>
Commit | Line | Data |
---|---|---|
59780c72 RD |
1 | |
2 | import wx | |
3 | ||
4 | #---------------------------------------------------------------------- | |
5 | ||
6 | class TestPanel(wx.Panel): | |
7 | def __init__(self, parent, log): | |
8 | self.log = log | |
9 | wx.Panel.__init__(self, parent, -1) | |
10 | ||
11 | wx.StaticText(self, -1, | |
12 | "On the Mac these squares should be transparent,\n" | |
13 | "if the CoreGrahics option is turned on.", | |
14 | (20, 20)) | |
15 | ||
16 | self.Bind(wx.EVT_PAINT, self.OnPaint) | |
17 | ||
18 | def OnPaint(self, evt): | |
19 | dc = wx.PaintDC(self) | |
20 | rect = wx.Rect(0,0, 100, 100) | |
21 | for RGB, pos in [((178, 34, 34), ( 50, 70)), | |
22 | (( 35, 142, 35), (110, 130)), | |
23 | (( 0, 0, 139), (170, 70)) | |
24 | ]: | |
25 | r, g, b = RGB | |
26 | penclr = wx.Colour(r, g, b, wx.ALPHA_OPAQUE) | |
27 | brushclr = wx.Colour(r, g, b, 128) # half transparent | |
28 | dc.SetPen(wx.Pen(penclr)) | |
29 | dc.SetBrush(wx.Brush(brushclr)) | |
30 | rect.SetPosition(pos) | |
31 | dc.DrawRectangleRect(rect) | |
32 | ||
33 | ||
34 | #---------------------------------------------------------------------- | |
35 | ||
36 | def runTest(frame, nb, log): | |
37 | win = TestPanel(nb, log) | |
38 | return win | |
39 | ||
40 | #---------------------------------------------------------------------- | |
41 | ||
42 | ||
43 | ||
44 | overview = """<html><body> | |
45 | <h2><center>Alpha Drawing</center></h2> | |
46 | ||
47 | The wx.DC on Mac now supports alpha transparent drawing using pens and | |
48 | brushes. This is accomplished by enabling the wx.Colour class to have | |
49 | a fourth component for the alpha value, where 0 is fully transparent, | |
50 | and 255 is fully opaque. | |
51 | ||
52 | </body></html> | |
53 | """ | |
54 | ||
55 | ||
56 | ||
57 | if __name__ == '__main__': | |
58 | import sys,os | |
59 | import run | |
60 | run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:]) | |
61 |