1 #-------------------------------------------------
3 from wxPython
.wx
import *
6 class MyFrame(wxFrame
):
7 def __init__(self
,parent
,title
,id):
8 wxFrame
.__init
__(self
,parent
,title
,id,
9 wxPoint(100,100),wxSize(300,300))
12 self
.SetBackgroundColour(wxWHITE
)
13 self
.windowx
,self
.windowy
=self
.GetClientSizeTuple()
15 # make a memory DC to draw into...
16 self
.mask
=wxMemoryDC()
18 self
.maskbitmap
=wxEmptyBitmap(self
.windowx
,self
.windowy
)
19 self
.mask
.SelectObject(self
.maskbitmap
)
20 self
.mask
.SetBackgroundMode(wxTRANSPARENT
)
22 self
.mask
.SetDeviceOrigin(0,0)
24 self
.mask
.SetBrush(wxBrush(wxColour(150,160,0),wxSOLID
))
25 self
.mask
.SetPen(wxPen(wxColour(1,2,3),1,wxSOLID
))
26 self
.mask
.DrawRectangle(0,0,self
.windowx
,self
.windowy
)
28 img
= wxImageFromBitmap(self
.maskbitmap
)
29 print (img
.GetRed(0,0), img
.GetGreen(0,0), img
.GetBlue(0,0))
32 def OnPaint(self
,evt
):
33 """ overriding OnPaint to give handler. """
36 dc
.Blit(0,0,self
.windowx
,self
.windowy
,self
.mask
,0,0,wxCOPY
)
38 #-----------------------------------------------------------
40 if __name__
== "__main__":
44 self
.frame
= MyFrame(NULL
, -1, "Blit Test")
50 app
= MyApp(0) # Create an instance of the application
51 app
.MainLoop() # Tell it to start processing events