Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8105925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:18:04+00:00 2026-06-06T00:18:04+00:00

I have a function for drawing gradient text which works great on mac, but

  • 0

I have a function for drawing gradient text which works great on mac, but isn’t working properly on windows.

I put it together in a runnable example:

import wx

def get_gradient_text_solid_bg(text,point_size,top_colour,bottom_colour,bg_colour_tuple):
    dc=wx.MemoryDC()
    f= dc.GetFont()
    f.SetPointSize(point_size)
    dc.SetFont(f)
    dc.SelectObject(wx.EmptyBitmap(0,0))
    w,h= dc.GetTextExtent(text)
    template_bmp= wx.EmptyBitmap(w,h)
    dc.SelectObject(template_bmp)
    dc.SetBackground(wx.Brush(wx.WHITE))
    dc.Clear()
    dc.DrawText(text,0,0)
    dc.SelectObject(wx.NullBitmap)
    template_image= template_bmp.ConvertToImage()
    template_image.ConvertColourToAlpha(*bg_colour_tuple)
    template_bmp= template_image.ConvertToBitmap()
    text_bmp= wx.EmptyBitmap(w,h)
    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

class Frame(wx.Frame):
    def __init__(self,*args,**kwargs):
        wx.Frame.__init__(self,*args,**kwargs)
        panel= wx.Panel(self)
        bg_colour= (237,237,237)
        panel.SetBackgroundColour(wx.Colour(*bg_colour))
        wx.StaticBitmap(panel,bitmap=get_gradient_text_solid_bg("Testing",30,(255,80,80),(255,215,215),bg_colour))
        self.Show()

if __name__ == "__main__":
    app= wx.App(False)
    Frame(None)
    app.MainLoop()

I’m not sure exactly why it isn’t working, I thought it was because the wxImage doesn’t seem to have an alpha channel on windows but you can see some of the reds come through in the text so I think there must be some alpha in the Image on the edges (anti-aliased parts) so maybe this is a problem with ConvertColourToAlpha on windows? How can I get this to appear the same on windows?

On MacOn Windows

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T00:18:05+00:00Added an answer on June 6, 2026 at 12:18 am

    I found the solution to this with the help of Robin.

    It is a bug with C++, I’ve created a tracker on the wxpython bug tracker but a work around is to set the bit depth to 24 text_bmp= wx.EmptyBitmap(w,h,24)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a drawing function that just takes an HDC. But I need to
I have function LoadTempMovieList(), and need to load movies from sessionStorage. But it seems
I have function some_func_1 which will create an object of type some_type and will
Have a simple drawing application. The problem is in the coordinates ( redraw function):
Hi have already function solution but one issue: // The screenshot will be stored
I have a single template file which renders pages that look very similar, but
I have a function which extracts a file into a byte array (data). int
I have a function receiving a Drawing that I need to partially expose as
I have a function that dynamically adds text to an image in a predesignated
I have a function that accepts CanvasRenderingContext2D as a parameter and does the drawing.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.