def __init__(self, parent, ID): wx.ScrolledWindow.__init__(self, parent, ID) self.shapes = [] self.dragImage = None self.dragShape = None self.hiliteShape = None self.SetCursor(wx.StockCursor(wx.CURSOR_ARROW)) self.bg_bmp = images.getBackgroundBitmap() self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) # Make a shape from an image and mask. This one will demo # dragging outside the window bmp = images.getTestStarBitmap() #bmp = wx.Bitmap('bitmaps/toucan.png') shape = DragShape(bmp) shape.pos = (5, 5) shape.fullscreen = True self.shapes.append(shape) # Make a shape from some text text = "Some Text" bg_colour = wx.Colour(57, 115, 57) # matches the bg image font = wx.Font(15, wx.ROMAN, wx.NORMAL, wx.BOLD) textExtent = self.GetFullTextExtent(text, font) # create a bitmap the same size as our text bmp = wx.EmptyBitmap(textExtent[0], textExtent[1]) # 'draw' the text onto the bitmap dc = wx.MemoryDC() dc.SelectObject(bmp) dc.SetBackground(wx.Brush(bg_colour, wx.SOLID)) dc.Clear() dc.SetTextForeground(wx.RED) dc.SetFont(font) dc.DrawText(text, 0, 0) dc.SelectObject(wx.NullBitmap) mask = wx.Mask(bmp, bg_colour) bmp.SetMask(mask) shape = DragShape(bmp) shape.pos = (5, 100) shape.text = "Some dragging text" self.shapes.append(shape) bmp = images.getTheKidBitmap() shape = DragShape(bmp) shape.pos = (200, 5) self.shapes.append(shape) self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp) self.Bind(wx.EVT_MOTION, self.OnMotion) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveWindow)