]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/ImageAlpha.py
cf1a7a2fd64035704c9f6e6bfaa16c08f50a4cdf
[wxWidgets.git] / wxPython / demo / ImageAlpha.py
1
2 import wx # This module uses the new wx namespace
3 from Main import opj
4
5
6 #----------------------------------------------------------------------
7
8 msg = "This is some text that will appear behind the image..."
9
10 class 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))
24 dc.DrawText("Bitmap alpha blending (on wxMSW and wxMac)",
25 (25,25))
26
27 bmp = wx.Bitmap(opj('bitmaps/toucan.png'))
28 dc.DrawBitmap(bmp, (25,100), True)
29
30 dc.SetFont(self.GetFont())
31 y = 75
32 for line in range(10):
33 y += dc.GetCharHeight() + 5
34 dc.DrawText(msg, (200, y))
35 dc.DrawBitmap(bmp, (250,100), True)
36
37
38
39 #----------------------------------------------------------------------
40
41 def runTest(frame, nb, log):
42 win = TestPanel(nb, log)
43 return win
44
45 #----------------------------------------------------------------------
46
47
48
49 overview = """<html><body>
50 <h2><center>Images with Alpha</center></h2>
51
52 wxMSW and wxMac now support alpha channels of supported image
53 types, and will properly blend that chennel when drawing a
54 bitmap. It is not supported yet on wxGTK, (if you would like to
55 change that please submit a patch!)
56
57 </body></html>
58 """
59
60
61
62 if __name__ == '__main__':
63 import sys,os
64 import run
65 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
66