Gradient Text update from wxPython 2 to Phoenix

1,223 views
Skip to first unread message

Mihails Murasovs

unread,
Aug 5, 2019, 11:22:12 AM8/5/19
to wxPython-users
Hi. I'm in the process of updating to Phoenix and the gradient text doesn't render anymore (example).

This is the code I was using in wx 2:

def get_gradient_text_solid_bg(text,font,font_style,point_size,top_colour,bottom_colour,bg_colour_tuple):
dc=wx.MemoryDC()
f=getFont(font,font_style)
f.SetFaceName(font)
f.SetPointSize(point_size)
dc.SetFont(f)
dc.SelectObject(wx.Bitmap(0,0,settings.DEFAULT_BITMAP_DEPTH))
w,h= dc.GetTextExtent(text)
template_bmp= wx.Bitmap(w,h,settings.DEFAULT_BITMAP_DEPTH)
dc.SelectObject(template_bmp)
dc.SetBackground(wx.Brush(settings.BG_COLOUR))
dc.Clear()
dc.DrawText(text,0,0)
dc.SelectObject(wx.NullBitmap)
template_image= template_bmp.ConvertToImage()
template_bmp= template_image.ConvertToBitmap()
text_bmp= wx.Bitmap(w,h,settings.DEFAULT_BITMAP_DEPTH)
dc.SelectObject(text_bmp)
dc.GradientFillLinear((0,0,w,h),top_colour,bottom_colour,wx.SOUTH)
dc.DrawBitmap(template_bmp,0,0)
dc.SelectObject(wx.NullBitmap)

return text_bmp

I looked at the differences between the two versions but couldn't find anything.

Any pointers would be much appreciated.

Thanks!



Tim Roberts

unread,
Aug 5, 2019, 12:31:09 PM8/5/19
to wxpytho...@googlegroups.com
Mihails Murasovs wrote:

Hi. I'm in the process of updating to Phoenix and the gradient text doesn't render anymore (example).

This is the code I was using in wx 2:

I don't understand how this is supposed to work.  You draw text into template_bmp in an unspecified foreground color with a BG_COLOUR background.  Then you gradient fill text_bmp and overwrite the whole thing with template_bmp.  What did you expect this to produce?  What is the end result supposed to be?

And what do you believe this accomplished?

    template_image = template_bmp.ConvertToImage()
    template_bmp = template_image.ConvertToBitmap()

-- 
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.
Reply all
Reply to author
Forward
0 new messages