John Hunter <[EMAIL PROTECTED]> writes:
> Nice. I tried this. Surprisingly, on my system at least, the icon
> for the default gtk.STOCK_CANCEL and my stock hide look different (see
> script below), and the stock hide is more primitive (perhaps from an
> older GTK)
>
> I don't know if this is a path issue or a problem with the approach.
It's probably a problem with my implementation of the approach.
Looking again at the gtk+ docs I see I disregarded a warning to use
style_lookup_icon_set() instead of icon_factory_lookup_default(). If
I understand this correctly, icon_factory_lookup_default() might not
pick up themed icons correctly.
When I tried your example all the icons looked the same, but this may
be do to differences in default theme or gtk+ version. Try this code
which uses gtk.style_lookup_icon_set() to see if it works better:
import pygtk
pygtk.require('2.0')
import gtk
def register_stock_icons(gtk_style):
items = [
('jdh-hide', '_Hide', 0, 0, None),
('jdh-auto', '_Auto', 0, 0, None),
]
aliases = [
('jdh-hide', gtk.STOCK_CANCEL),
('jdh-auto', gtk.STOCK_EXECUTE),
]
gtk.stock_add(items)
factory = gtk.IconFactory()
factory.add_default()
for new_stock, alias in aliases:
#icon_set = gtk.icon_factory_lookup_default(alias)
icon_set = gtk_style.lookup_icon_set(alias)
factory.add(new_stock, icon_set)
window = gtk.Window()
window.connect("destroy", gtk.mainquit)
vbox = gtk.VBox(spacing=3)
window.add(vbox)
vbox.show()
register_stock_icons(window.get_style())
button = gtk.Button(stock=gtk.STOCK_CANCEL)
button.show()
vbox.pack_start(button)
button = gtk.Button(stock='jdh-hide')
button.show()
vbox.pack_start(button)
button = gtk.Button(stock=gtk.STOCK_CANCEL)
button.show()
alignment = button.get_children()[0]
hbox = alignment.get_children()[0]
image, label = hbox.get_children()
label.set_text('Hide')
vbox.pack_start(button)
window.show()
gtk.mainloop()
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/