Hello, I'm no gtk specialist, but my understanding is that - 'import gtk' (not Gtk) implies using the pygtk bindings (--> gtk 2) - 'from gi.repository import Gtk' implies using the GObject Introspection bindings (--> gtk 3)
If I'm not mistaken, GObject Introspection bindings are automatically generated for libraries supporting them. It allows creating bindings for many programming languages automatically (Python included). For instance libpoppler provides GI bindings as well and they can be imported with "from gi.repository import Poppler. The visible side effect is that all Python programs must import these bindings by using the pattern "from gi.repository import <X>". Hope it helps, 2013/2/27 ruwan thushara <[email protected]> > Hi > I designed ui using glade and connect it with python code. when i use > "import Gtk" In the python code it gives import error in the terminal like > below, > Traceback (most recent call last): > File "test.py", line 1, in <module> > import Gtk > ImportError: No module named Gtk > > But when i use "from gi.repository import Gtk" it works as expected. > problem is why can't I just import Gtk in to the code? > > Thanx > > _______________________________________________ > gnome-love mailing list > [email protected] > https://mail.gnome.org/mailman/listinfo/gnome-love > >
_______________________________________________ gnome-love mailing list [email protected] https://mail.gnome.org/mailman/listinfo/gnome-love
