minor gtk issues with 0.64

Thanks for matplotlib 0.64. Great to see steady improvements continue to roll in.

First the good news. IPython (0.6.4) using pylab works for me again. It broke with 0.63 / 0.6.3 and gtk 2.4.x, complaining about gtk mainloop and gtk main in the middle of the IPython prompt and then freezing up.

I had some minor issues with my GTK matplotlib API code.

1. I had to change

toolbar = NavigationToolbar(canvas)

to

toolbar = NavigationToolbar(canvas, win)

where win is the GTK window object. I guess the matplotlib API is still unstable. :slight_smile:

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.

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:

frog.py (163 Bytes)

tadpole.py (26 Bytes)

embedding_in_gtk2.py (1.04 KB)

···

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.

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):

...

"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'

Its now fixed in CVS. backend_gtk now knows about all image formats and
does not need to look at other backends to see what formats they
support.

Steve

···

On Tue, 2004-11-16 at 17:45 +1100, matthew arnison wrote:

Returning after a time to my animation project.

The first thing i did was to make sure anim_tk.py still runs. It didn't. A ghost figure window appears, and there is a long stall, then the message:

elapsed 10.7956385487
Fatal Python error: PyEval_RestoreThread: NULL tstate

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

Is it me, or did something break?
WinXP, matplotlib 0.64, recently installed by deleting the existing matplolib directory and installing using the windows installer. Examples installed from the latest zip.

thanks,
gary

Its working OK for me.
Fedora 3 Linux, matplotlib 0.64, Python 2.3.4

Steve

···

On Thu, 2004-11-18 at 18:14 -0500, Gary wrote:

Returning after a time to my animation project.

The first thing i did was to make sure anim_tk.py still runs. It
didn't. A ghost figure window appears, and there is a long stall, then
the message:

elapsed 10.7956385487
Fatal Python error: PyEval_RestoreThread: NULL tstate

This application has requested the Runtime to terminate it in an unusual
way.
Please contact the application's support team for more information.

Is it me, or did something break?
WinXP, matplotlib 0.64, recently installed by deleting the existing
matplolib directory and installing using the windows installer.
Examples installed from the latest zip.

thanks,
gary

Steve Chaplin wrote:

···

On Thu, 2004-11-18 at 18:14 -0500, Gary wrote:

Returning after a time to my animation project.

The first thing i did was to make sure anim_tk.py still runs. It didn't. A ghost figure window appears, and there is a long stall, then the message:

elapsed 10.7956385487
Fatal Python error: PyEval_RestoreThread: NULL tstate

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

Is it me, or did something break?
WinXP, matplotlib 0.64, recently installed by deleting the existing matplolib directory and installing using the windows installer. Examples installed from the latest zip.

thanks,
gary
   

Its working OK for me.
Fedora 3 Linux, matplotlib 0.64, Python 2.3.4

Steve

Thanks ... so it's either me or WinXP. I gave it a try on my other WinXP machine. Same thing. No dice.

Can someone confirm that anim_tk.py runs (or doesn't) on WinXP / matplotlib 0.64 ??

Thanks,
gary