Replace Image Using Gtk.image.set_from_file
I'm trying to add and if needed by user, change the image from a widget in python. I'm using Glade with gtk2+, python 2.7.3, and these is what I'm doing image = gtk.Image() image.
Solution 1:
You either have to remove the old image from the button before adding a new one (the error message is pretty straightforward about this), or you could try changing the current image:
button.get_child().set_from_file("MyImagePath.png")
Solution 2:
This was exactly what I needed. I used the clear in the image as you said and also cleaned the button image, as follows:
App.get_object('buttonExample').remove(image)
image.clear()
Thank you very much for you help!
Post a Comment for "Replace Image Using Gtk.image.set_from_file"