]> git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/wxPIA_book/Chapter-08/shaped_frame.py
don't use invalid wxIconBundles, it results in asserts after recent changes
[wxWidgets.git] / wxPython / samples / wxPIA_book / Chapter-08 / shaped_frame.py
1 import wx
2 import images
3
4 class ShapedFrame(wx.Frame):
5 def __init__(self):
6 wx.Frame.__init__(self, None, -1, "Shaped Window",
7 style = wx.FRAME_SHAPED | wx.SIMPLE_BORDER |
8 wx.FRAME_NO_TASKBAR)
9 self.hasShape = False
10 self.bmp = images.getVippiBitmap()
11 self.SetClientSize((self.bmp.GetWidth(), self.bmp.GetHeight()))
12 dc = wx.ClientDC(self)
13 dc.DrawBitmap(self.bmp, 0,0, True)
14 self.SetWindowShape()
15 self.Bind(wx.EVT_LEFT_DCLICK, self.OnDoubleClick)
16 self.Bind(wx.EVT_RIGHT_UP, self.OnExit)
17 self.Bind(wx.EVT_PAINT, self.OnPaint)
18 self.Bind(wx.EVT_WINDOW_CREATE, self.SetWindowShape)
19
20 def SetWindowShape(self, evt=None):
21 r = wx.RegionFromBitmap(self.bmp)
22 self.hasShape = self.SetShape(r)
23
24 def OnDoubleClick(self, evt):
25 if self.hasShape:
26 self.SetShape(wx.Region())
27 self.hasShape = False
28 else:
29 self.SetWindowShape()
30
31 def OnPaint(self, evt):
32 dc = wx.PaintDC(self)
33 dc.DrawBitmap(self.bmp, 0,0, True)
34
35 def OnExit(self, evt):
36 self.Close()
37
38 if __name__ == '__main__':
39 app = wx.PySimpleApp()
40 ShapedFrame().Show()
41 app.MainLoop()
42
43