Re: [pygtk] python and GTK+-3 - possible?
- From: John Stowers <john stowers lists gmail com>
- To: John Lumby <johnlumby hotmail com>
- Cc: python-hackers-list gnome org, pygtk_pygobject maillist <pygtk daa com au>
- Subject: Re: [pygtk] python and GTK+-3 - possible?
- Date: Wed, 16 Mar 2011 16:07:48 +1300
On Tue, 2011-03-15 at 22:31 -0400, John Lumby wrote:
> R Park wrote:
> >
> > From what I understand, pygobject can only provide GTK3 and pygtk can
> > only provide GTK2. So if your code includes 'import pygtk' then that
> > is by definition gtk2 you are using, and if instead you have 'from
> > gi.repository import Gtk' then that can only be Gtk3.
Almost, for the bulk of my answer see below. However, there is some
crusty subtlety when calling
>>> import pygtk
pygtk.py (what gets executed above) lives in pygobject. This, for
historical reasons lived there to help easy the pain of the pygtk-1 ->
pygtk-2 transition. This is why you see pygtk.require(2.0) at the top of
some programs (although this has not been necessary for some time).
pygtk.py does some things with sys.path to choose which native code gets
imported. We might start requiring people to call pygtk.require(2.0)
again in future, depending on the parallel installation capabilities of
the static parts of pygobject, however I think that discussion is
ongoing, and not something you should worry about (Dieter, J5, is that
correct, I have been AFK for a while)
> >
>
> Many thanks.
>
> Actually I think it's possible that
> 'from gi.repository import Gtk'
> may give you GTK+2; I think it depends on which (version of) GTK
> was introspected into whichever gi repository your python finds.
> Not suggesting this is what you want - just my experience.
This is not correct. One can choose the version of the typelib to be
loaded; e.g.
>>> import gi
>>> gi.require_version("Gtk", "2.0")
>>> from gi.repository import Gtk
>>> Gtk.Switch
--> Fails
But the annotations are most up to date in the Gtk-3 overrides, so I
would suggest letting it choose the most recent typelib by default, that
is
>>> from gi.repository import Gtk
>>> Gtk.Switch
---> Works
And gives you gtk+-3.
If you want to use gtk+-2 I suggest you stick with pygtk.
John
>
> > Check the source to my app, it's gtk3 and uses some of the new gtk3
> > widgets (such as ComboBoxText for example):
> >
> > https://github.com/robru/gottengeography
>
> Thanks again. That helped. I got mine working now (with a GTK+3 Light Switch)
>
> Cheers, John
>
>
> _______________________________________________
> pygtk mailing list pygtk daa com au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]