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

  • Home
  • SEARCH
  • 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 859479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:41:10+00:00 2026-05-15T08:41:10+00:00

Here is the code that I have so far to define the icon: icon_bg

  • 0

Here is the code that I have so far to define the icon:

icon_bg = gtk.gdk.pixbuf_new_from_file('gmail.png')
w, h = icon_bg.get_width(), icon_bg.get_height()
cmap = gtk.gdk.Colormap(gtk.gdk.visual_get_system(), False)

drawable = gtk.gdk.Pixmap(None, w, h, 24)
drawable.set_colormap = cmap
gc = drawable.new_gc()
drawable.draw_pixbuf(gc, icon_bg, 0, 0, 0, 0, w, h)

drawn_icon = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, w, h)
drawn_icon.get_from_drawable(drawable, cmap, 0, 0, 0, 0, w, h)
icon = gtk.status_icon_new_from_pixbuf(drawn_icon)

This works to get the png into the icon, but falls short in two areas. First, transparency is not working. If I use a 22×22 png with transparent background and the image centered, I end up with sections of other active icons showing up inside of mine, like this:

http://i237.photobucket.com/albums/ff311/Raugturi/22x22_image_with_transparency.png

The icon it choose to steal from is somewhat random. Sometimes it’s part of the dropbox icon, others the NetworkManager Applet.

If I instead use this code:

icon_bg = gtk.gdk.pixbuf_new_from_file('gmail.png')
w, h = icon_bg.get_width(), icon_bg.get_height()
cmap = gtk.gdk.Colormap(gtk.gdk.visual_get_system(), False)

drawable = gtk.gdk.Pixmap(None, w, h, 24)
drawable.set_colormap = cmap
gc = drawable.new_gc()
drawable.draw_pixbuf(gc, icon_bg, 0, 0, 0, 0, w, h)

drawn_icon = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, 22, 22)
drawn_icon.get_from_drawable(drawable, cmap, 0, 0, 3, 6, w, h)
icon = gtk.status_icon_new_from_pixbuf(drawn_icon)

And an image that is only 16×11 with the transparent edges removed, what I end up with is this:

http://i237.photobucket.com/albums/ff311/Raugturi/16x11_image_positioned_in_middle.png

So how do I end up with a transparent block like the 1st one that doesn’t pull in stuff from other icons?

As for the second problem, I need the ability to write on the image before converting it to the icon. I tried using draw_glyphs and it told me I should be using Pango layout/context instead. Unfortunately all the Pango tutorials I could find deal with actual windows, not the status icon. Is there a good tutorial out there for Pango that would apply to this issue (and also maybe have at least some explanation of how to tell it what font to use as all of them that I found seem to lack this and it won’t write anything without it).

Note: Sorry for the lack of actual images and only one working link, apparently this is a spam prevention feature due to my lack of reputation.

  • 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-05-15T08:41:11+00:00Added an answer on May 15, 2026 at 8:41 am

    Is there a reason you can’t just use gtk.StatusIcon.set_from_file? It works fine with transparent images.

    As for your second question, I highly doubt that it is possible to use pango on a gtk.StatusIcon.
    Why do you need to write text on the icon?

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

Sidebar

Related Questions

We have some old C code here that's built with nmake. Is there an
I have a piece of code here that i really could use some help
Here's the situation: We have some generic graphics code that we use for one
Here are two chunks of code that accomplish (what I think is) the same
Here is an interesting piece of code that my fellow team members were just
In writing the code that throws the exception I asked about here , I
Given some JS code like that one here: for (var i = 0; i
Here's a wierd one. I'm reusing a code base that unfortunately must not be
Here's the code from the ascx that has the repeater: <asp:Repeater ID=ListOfEmails runat=server >
Here's my code in a gridview that is bound at runtime: ... <asp:templatefield> <edititemtemplate>

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.