3

I'm nearly new to python and new to gtk.

I just can't figure out, why I get this error message:

self.builder.get_object("checkstatus").set_from_stock("gtk-yes", Gtk.ICON_SIZE_BUTTON)
.......
AttributeError: 'gi.repository.Gtk' object has no attribute 'ICON_SIZE_BUTTON'

At the beginning I'm importing:

import pygtk
pygtk.require('2.0')
from gi.repository import Gtk

So the problem is that gtk has no no attribute called 'ICON_SIZE_BUTTON'? But when I look at the documentation it says so...

http://developer.gnome.org/pygtk/2.22/class-gtkimage.html#method-gtkimage--set-from-stock

I would appreciate any help. Thanks!

1 Answer 1

8

Well, there's a few things going on.

For GTK+ 3 which uses PyGObject, you use from gi.repository import Gtk and then use Gtk.IconSize.BUTTON.

For GTK+ 2 which uses PyGTK you use import pygtk and import gtk and then use gtk.ICON_SIZE_BUTTON.

In other words, you're mixing up versions. PyGTK (GTK 2) was replaced by PyGObject and something called "gobject introspection" in GTK 3. Check out this tutorial: http://python-gtk-3-tutorial.readthedocs.org/en/latest/index.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.