Wednesday, 15 May 2013

python - PyGObject and Glade, dynamically changing icon of a button -



python - PyGObject and Glade, dynamically changing icon of a button -

how dynamically alter icon of button created glade?

______________________ lastly edit _________________________________________

i'm trying this:

self.button_waiting=self.builder.get_object('button_waiting') image=gtk.image() image.set_from_stock(gtk.stock_dialog_error, gtk.iconsize.button) image.show() self.button_waiting.remove(image) self.button_waiting.add(image)

i error:

gtk-critical **: gtk_container_remove: assertion `gtk_widget_get_parent (widget) == gtk_widget (container) || gtk_is_assistant (container)' failed (fresh_install:16299): gtk-warning **: attempting add together widget type gtkimage gtkbutton, gtkbin subclass gtkbutton can contain 1 widget @ time; contains widget of type gtklabel

it seems error of reply i'm copying, doing did not working me.

i read possible set images on labels, how can name of label of button made in glade?

following answer: replace image using gtk.image.set_from_file

___________________ original question _________________________________ i'm trying this:

self.button_waiting=self.builder.get_object('button_waiting') self.button_waiting.set_label("cancel") image=gtk.image.set_from_stock(gtk.stock_dialog_error, gtk.icon_size_button) image.show() self.button_waiting.image.clear() self.button_waiting.add(image)

i next error:

attributeerror: 'gi.repository.gtk' object has no attribute 'icon_size_button'

but found gtk_icon_size_button on reference manual >.<

i'm going assume using pygobject (gtk+ 3.x) based on fact you're gtk instead of gtk. if that's case, should utilize gtk.iconsize.button rather gtk.icon_size_button.

this because gobject introspection set constants namespace rather long constants see in c source code. it's pretty easy figure out based on context.

python glade pygobject

No comments:

Post a Comment