13.07.2015 Views

The wxPython tutorial

The wxPython tutorial

The wxPython tutorial

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>The</strong> Graphics Device Interfacehttp://www.zetcode.com/wxpython/gdi/If we remove a border from the frame, we cannot move thewindow. <strong>The</strong> OnLeftDown() and the OnMouseMove() methodsenable the user to move the window by clicking on the clientarea of the frame and dragging it.dc.DrawBitmap(self.bitmap, 0, 0, True)dc.DrawBitmap(self.cross, 170, 10, True)dc.DrawText('- Go shopping', 20, 20)dc.DrawText('- Make a phone call', 20, 50)dc.DrawText('- Write an email', 20, 80)Within the OnPaint() method we draw two bitmaps and threetexts.Finally we will talk about how we close the note script.self.bitmapRegion = wx.RegionFromBitmap(self.bitmap)self.crossRegion = wx.RegionFromBitmap(self.cross)self.bitmapRegion.IntersectRegion(self.crossRegion)self.bitmapRegion.Offset(170, 10)...pos = event.GetPosition()if self.bitmapRegion.ContainsPoint(pos):self.Close()We create two regions from two bitmaps. We intersect thesetwo regions. This way we get all pixels that share bothbitmaps. Finally we move the region to the point, where wedraw the cross bitmap. We use the Offset() method. Bydefault the region starts at [0, 0] point.Inside the OnLeftDown() method we check if we clicked insidethe region. If true, we close the script.43 de 44 27/04/2008 1:08

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!