I notice that pygtk.require('2.0') calls have appeared in
backend_gtk.py and backend_gdk.py
It has not appeared, its been used since matplotlib 0.53 at least,
I am not convinced that library code should include calls to
The problem is that pygtk.require() has to be called >before<
This means that if you are using gtk then you have two choices:
> 1. never use pygtk.require()
> 2. always precede any 'import gtk' with 'import pygtk' and
I have found that 1. works pretty well and prefer not to litter code
with the pygtk.require() boiler plate.
Unfortunately, approach 1. falls over if you use some library that
decides to use pygtk.require().
In the times when I do require a specific version of pygtk then I can
always create a simple wrapper that does the pygtk require stuff.
Now no doubt I'm missing some subtleties as to why it is good to have
these pygtk.require() calls in matplotlib. Is there any way to make
A half-way house would be to do something like this:
if not matplotlib.FROZEN and not sys.modules.has_key('gtk'):
print >> sys.stderr, sys.exc_info()
raise SystemExit('PyGTK version %d.%d.%d or greater is required to
'the GTK Matplotlib backends'
This code would ensure that the correct pygtk is loaded for people who
haven't already import'ed gtk without throwing an exception for those
that have loaded gtk prior to importing matplotlib.
The down side with this fix is that it doesn't help anyone who does
want the pygtk.require() but has made the mistake of importing gtk
I've never liked pygtk.require(), it tries to be clever by editing your
sys.path to solve one problem, but creates other problems like you describe,
so on balance you don't gain much, if anything.
The only situation it helps with is when you have pygtk 1 and 2 installed on
the same system AND pygtk 1 is ahead of pygtk 2 in sys.path. I think that is
increasing rare nowadays.
My vote is to remove it completely.
Send instant messages to your online friends http://au.messenger.yahoo.com
On Thu, 2005-07-14 at 10:52 -0700, email@example.com wrote: