[pygtk] issue using icon_theme_get_default()

daniele favara danjele at gmail.com
Tue Feb 7 23:14:58 WST 2006


hi all,

there is a strange issue using

icon_theme_get_default()

for ex:

icon_theme = gtk.icon_theme_get_default()

this will show the correct icon but without any colors,

icon_theme=gtk.IconTheme()

this will use the default icon, but not the one from the theme in use,
anyway the image has the correct colors.

please try out the following script, you should understand better what i mean.

if you see any solution for this issue please let me know.

thanks

ciao

df



-------------------------
import pygtk
pygtk.require('2.0')
import gtk
import os

class Dicon:
    def __init__(self,name):
        self.win=gtk.Window()
        #icon=self.get_icon_path(name)
        #if icon==None:
        #    icon=self.get_icon_path(gtk.STOCK_MISSING_IMAGE)
        #print icon
        #icon="/usr/share/icons/Tango/scalable/devices/gtk-cdrom.svg"
        #pixbuf = gtk.gdk.pixbuf_new_from_file(icon)
        icon_theme = gtk.icon_theme_get_default()
        #icon_theme=gtk.IconTheme()
        pixbuf=icon_theme.load_icon(name,48 ,gtk.ICON_LOOKUP_FORCE_SVG)
        pixmap, mask = pixbuf.render_pixmap_and_mask()
        width, height = pixmap.get_size()
        self.win.set_app_paintable(True)
        self.win.resize(width, height+15)
        self.win.realize()
        self.win.shape_combine_mask(mask, 0, 0)
        #self.win.window.set_back_pixmap(pixmap, False)
        self.win.queue_draw()

    def get_icon_path(self, iconname):
        icontheme = gtk.icon_theme_get_default()
        if icontheme.has_icon(iconname) == True:
            icon_lookup=icontheme.lookup_icon(iconname,48
,gtk.ICON_LOOKUP_FORCE_SVG)
            icon=icon_lookup.get_filename()
            return icon
dicon=Dicon("gtk-cdrom")
dicon.win.show()
gtk.main()


More information about the pygtk mailing list