|
From: matthew a. <ma...@ca...> - 2004-11-16 06:45:50
|
Oh dear. I'm going to take another u-turn, and say I hit this
IMAGE_FORMAT attribute glitch again.
To atone for my reversals, I have isolated a test case, and I attach
sample code. It seems to be triggered by importing matplotlib.matlab in
one module, and importing matplotlib backend stuff directly in another
module.
Running frog.py gives:
Traceback (most recent call last):
File "frog.py", line 4, in ?
embedding_in_gtk2_mra.plotme()
File "M:\home\My Documents\My
Downloads\matplotlib-0.64\matplotlib-0.64\examples\embedding_in_gtk2_mra.py",
line 39, in plotme
toolbar = NavigationToolbar(canvas, win)
File
"C:\Python23\lib\site-packages\matplotlib\backends\backend_gtk.py", line
963, in __init__
NavigationToolbar2.__init__(self, canvas)
File "C:\Python23\Lib\site-packages\matplotlib\backend_bases.py",
line 786, in __init__
self._init_toolbar()
File
"C:\Python23\lib\site-packages\matplotlib\backends\backend_gtk.py", line
1028, in _init_toolbar
self._init_toolbar2_4()
File
"C:\Python23\lib\site-packages\matplotlib\backends\backend_gtk.py", line
1091, in _init_toolbar2_4
parent=self.win,)
File
"C:\Python23\lib\site-packages\matplotlib\backends\backend_gtk.py", line
1423, in __init__
self.IMAGE_FORMAT =
matplotlib.backends.backend_mod.IMAGE_FORMAT
AttributeError: 'module' object has no attribute 'IMAGE_FORMAT'
As commented in the code, changing the order of the import statements in
frog.py avoids the bug. Or using the workaround I mentioned below.
Hmmm. Now I remember an email from John Hunter saying that pythonic
matplotlib should not be mixed with the matlab interface. Maybe this
glitch is an artefact of that. It does mean however that all my modules
have to use one API or the other.
Cheers,
Matthew.
matthew arnison wrote:
> 2. I was getting errors that the
> matplotlib.backends.backend_mod.IMAGE_FORMAT attribute was not found,
> during toolbar initialization. I put in a workaround.
>
> works with matplotlib 0.63:
>
> import matplotlib
> matplotlib.use('GTK')
>
> from matplotlib.backends.backend_gtk import FigureCanvasGTK
> from matplotlib.backends.backend_ps import FigureCanvasPS
> from matplotlib.backends.backend_gtk import NavigationToolbar2GTK as
> NavigationToolbar
>
> using matplotlib 0.64:
>
> import matplotlib
> matplotlib.use('GTK')
> from matplotlib.backends import backend_gtk
> matplotlib.backends.backend_mod = backend_gtk
>
> from matplotlib.backends.backend_gtk import FigureCanvasGTK
> from matplotlib.backends.backend_ps import FigureCanvasPS
> from matplotlib.backends.backend_gtk import NavigationToolbar2GTK as
> NavigationToolbar
>
> This style was cribbed from matplotlib examples and / or emails on this
> list.
>
> Cheers,
> Matthew.
|