$ apt-get install python-gi gir1.0-gtk-2.0
and then write applications like this:
from gi.repository import Gtk
def destroy_cb(widget):
Gtk.main_quit()
w = Gtk.Window()
w.connect('destroy', destroy_cb)
l = Gtk.Label()
l.set_text("Hello World!")
w.add(l)
w.show_all()
Gtk.main()
Have fun!
EDIT: Updated to note you need to install the GI package for the module you are using.
5 comments:
Not working for me
>>> from gi.repository import Gtk
Traceback (most recent call last):
File "", line 1, in
ImportError: cannot import name Gtk
i can import gi and gi.repository
@Promotux SNC:
You need to install gir1.0-gtk-2.0 as well.
Basically, you need the typelib for every library you want to call from python.
Are you planning create a PPA so that we can install it on Ubuntu 10.04 as well?
@Dzhelil, no because there are too many things it depends on that would also need updating.
had to install gir1.2-gtk-3.0 and gir1.2-webkit-3.0
Post a Comment