Skip to content

Instantly share code, notes, and snippets.

@Acorn-zz
Created July 12, 2011 23:06
Show Gist options
  • Save Acorn-zz/1079194 to your computer and use it in GitHub Desktop.
Save Acorn-zz/1079194 to your computer and use it in GitHub Desktop.
wxpython hole in transparent background attempt
import wx
class Frame(wx.Frame):
def __init__(self):
super(Frame, self).__init__(None)
self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
self.Bind(wx.EVT_PAINT, self.OnPaint)
self.SetTransparent(200)
def OnKeyDown(self, event):
if event.GetKeyCode() == wx.WXK_ESCAPE:
self.Close()
else:
event.Skip()
def OnPaint(self, event):
w, h = self.GetSize()
dc = wx.PaintDC(self)
dc.SetBrush(wx.BLUE_BRUSH)
region = wx.RegionFromPoints([(0, 0), (w, 0), (w, h), (0, h)])
box = wx.RegionFromPoints([(100, 100), (500, 100), (500, 500), (100, 500)])
region.SubtractRegion(box)
dc.SetClippingRegionAsRegion(region)
dc.DrawRectangle(0, 0, w, h)
if __name__ == '__main__':
app = wx.PySimpleApp()
frame = Frame()
frame.ShowFullScreen(True)
app.MainLoop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment