def generate(self): background = cache.get_bitmap(self.path) width, height = background.GetSize() page = core.Page() page.add(core.Bitmap(background)) text_width = width - self.padding * 2 header = core.Text( self.header.upper(), text_width, alignment=self.header_alignment, border_color=(0, 0, 0), border_size=self.border_size, color=(255, 255, 255), font=core.font('Impact', self.header_size), ) page.add(header, (width / 2, self.padding), (0.5, 0)) footer = core.Text( self.footer.upper(), text_width, alignment=self.footer_alignment, border_color=(0, 0, 0), border_size=self.border_size, color=(255, 255, 255), font=core.font('Impact', self.footer_size), ) page.add(footer, (width / 2, -self.padding), (0.5, 1)) bitmap = wx.EmptyBitmap(width, height) dc = wx.MemoryDC(bitmap) page.render(dc, (width, height), (0, 0)) return bitmap
def draw(self, dc): bitmap = cache.get_bitmap(self.bitmap) dc.DrawBitmap(bitmap, 0, 0, True)
def get_size(self): bitmap = cache.get_bitmap(self.bitmap) return bitmap.GetSize()