[pygtk] manipulate image from a gtk.Button

Matí­as Alejandro Torres torresmat at gmail.com
Tue Nov 27 21:38:59 WST 2007


awalter1 escribió:
> At the creation of the button, I use :
> image = gtk.Image()
> image.set_from_stock (gtk.STOCK_ADD, gtk.ICON_SIZE_BUTTON)
> button = gtk.Button()
> button.add (image)	
> On the 'changed' callback, I need to change the stock item to STOCK_REMOVE
> and the next time to STOCK_ADD.
>   
Maybe if you set the image with the set_image method,

image = gtk.Image()
image.set_from_stock (gtk.STOCK_ADD, gtk.ICON_SIZE_BUTTON)
button = gtk.Button()
button.set_image (image)

And when you want to change the image,

button.set_image (newImage)

If you can't use the set_image method, you'll have to keep a reference to the image you want to remove, remove it, add it to the container, and hide and show the button.




More information about the pygtk mailing list