]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/ImageAlpha.py
GetFirstChild does't need the cookie anymore
[wxWidgets.git] / wxPython / demo / ImageAlpha.py
CommitLineData
8a88769e
RD
1
2import wx # This module uses the new wx namespace
3from Main import opj
4
5
6#----------------------------------------------------------------------
7
8msg = "This is some text that will appear behind the image..."
9
10class TestPanel(wx.Panel):
11 def __init__(self, parent, log):
12 self.log = log
13 wx.Panel.__init__(self, parent, -1)
14
15 self.Bind(wx.EVT_PAINT, self.OnPaint)
16
17
18 def OnPaint(self, evt):
19 dc = wx.PaintDC(self)
20 dc.SetBackground(wx.Brush("WHITE"))
21 dc.Clear()
22
23 dc.SetFont(wx.Font(16, wx.SWISS, wx.NORMAL, wx.BOLD, True))
803a0ba6 24 dc.DrawText("Bitmap alpha blending (on wxMSW and wxMac only)",
8a88769e
RD
25 (25,25))
26
27 bmp = wx.Bitmap(opj('bitmaps/toucan.png'))
20ed8fab 28 if "__WXGTK__" in wx.PlatformInfo:
803a0ba6
RD
29 # try to make up for it a bit...
30 bmp.SetMaskColour("black")
31
8a88769e
RD
32 dc.DrawBitmap(bmp, (25,100), True)
33
34 dc.SetFont(self.GetFont())
35 y = 75
36 for line in range(10):
37 y += dc.GetCharHeight() + 5
38 dc.DrawText(msg, (200, y))
39 dc.DrawBitmap(bmp, (250,100), True)
40
41
42
43#----------------------------------------------------------------------
44
45def runTest(frame, nb, log):
46 win = TestPanel(nb, log)
47 return win
48
49#----------------------------------------------------------------------
50
51
52
53overview = """<html><body>
54<h2><center>Images with Alpha</center></h2>
55
8e43747f 56wxMSW and wxMac now support alpha channels of supported image
6a8fa617 57types, and will properly blend that channel when drawing a
8a88769e
RD
58bitmap. It is not supported yet on wxGTK, (if you would like to
59change that please submit a patch!)
60
803a0ba6
RD
61<p>On wxGTK this demo turns the alpha channel into a 1-bit mask, so
62yes, it looks like crap. Please help us fix it!
63
8a88769e
RD
64</body></html>
65"""
66
67
68
69if __name__ == '__main__':
70 import sys,os
71 import run
72 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
73