Created
July 12, 2011 23:06
-
-
Save Acorn-zz/1079194 to your computer and use it in GitHub Desktop.
wxpython hole in transparent background attempt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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