Wxpython Draw Text Onto Existing Bitmap Or Image
I'm trying to add a background image to some text, I'm hoping to do this by using MemoryDC to write text to an image which will then be placed in my GridSizer. Everything works as
Solution 1:
MemoryDC works on a Bitmap, not a StaticBitmap control.
Also, you can load Bitmaps directly, no need to use an Image object.
bitmap = wx.Bitmap(location)
dc = wx.MemoryDC(bitmap)
text = 'whatever'
w, h = dc.GetSize()
tw, th = dc.GetTextExtent(text)
dc.DrawText(text, (w - tw) / 2, (h - th) / 2) #display text in center
del dc
control = wx.StaticBitmap(self, -1, bitmap)
Post a Comment for "Wxpython Draw Text Onto Existing Bitmap Or Image"