Problems with pygtk and matplotlib

Hi

I'm trying to plot several subplots. I have setup a scrollwidget and
viewport and I pack a canvas into a vbox in the viewport.

Problem is that when I scroll, either some of the subplots are missing,
or I get an error when I try to zoom on a graph that argument is not a
gdk.gtk.image (or something like that) but None.

I thought this was fixed in 1.0, but it isn't

Please advice!

Thanks in advance.

Preben

Does this example work for you?

http://matplotlib.sourceforge.net/examples/user_interfaces/embedding_in_gtk3.html

It uses a ScrolledWindow.

Also, are you using backend_gtk or backend_gtkagg (and does it matter
for your problem?)

If you could create a minimal example starting with
embedding_in_gtk3.py that replicates your problem, we're more likely
to be able to help.

JDH

···

On Fri, Jul 9, 2010 at 3:10 PM, Preben Randhol <randhol@...3174...> wrote:

Hi

I'm trying to plot several subplots. I have setup a scrollwidget and
viewport and I pack a canvas into a vbox in the viewport.

Problem is that when I scroll, either some of the subplots are missing,
or I get an error when I try to zoom on a graph that argument is not a
gdk.gtk.image (or something like that) but None.

I thought this was fixed in 1.0, but it isn't

Please advice!

Does this example work for you?

  http://matplotlib.sourceforge.net/examples/user_interfaces/embedding_in_gtk3.html

It uses a ScrolledWindow.

Also, are you using backend_gtk or backend_gtkagg (and does it matter
for your problem?)

If you could create a minimal example starting with
embedding_in_gtk3.py that replicates your problem, we're more likely
to be able to help.

JDH

···

On Fri, Jul 9, 2010 at 3:10 PM, Preben Randhol <randhol@...3174...> wrote:

I'm trying to plot several subplots. I have setup a scrollwidget and
viewport and I pack a canvas into a vbox in the viewport.

Problem is that when I scroll, either some of the subplots are missing,
or I get an error when I try to zoom on a graph that argument is not a
gdk.gtk.image (or something like that) but None.

I thought this was fixed in 1.0, but it isn't

Please advice!

> I'm trying to plot several subplots. I have setup a scrollwidget and
> viewport and I pack a canvas into a vbox in the viewport.
>
> Problem is that when I scroll, either some of the subplots are
> missing, or I get an error when I try to zoom on a graph that
> argument is not a gdk.gtk.image (or something like that) but None.
>
> I thought this was fixed in 1.0, but it isn't
>
> Please advice!

Does this example work for you?

  http://matplotlib.sourceforge.net/examples/user_interfaces/embedding_in_gtk3.html

Yes it works and a bit cleanup of my imports helped in my program too.
However if I add NavigateToolbar to the example above I get problems.

mtoolbar = NavigationToolbar(canvas, win)

then I get error when I try to zoom in a graph:

/usr/lib/pymodules/python2.6/matplotlib/backends/backend_gtk.py:621:
DeprecationWarning: Use the new widget gtk.Tooltip self.tooltips =
gtk.Tooltips() /usr/lib/pymodules/python2.6/matplotlib/backends/backend_gtk.py:601:
GtkWarning: gdk_drawable_copy_to_image: assertion `src_y >= 0' failed
self._imageBack = axrect, drawable.get_image(*axrect) Traceback (most
recent call last): File
"/usr/lib/pymodules/python2.6/matplotlib/backends/backend_gtk.py", line
606, in idle_draw drawable.draw_image(gc, imageBack, 0, 0, *lastrect)
TypeError: Gdk.Drawable.draw_image() argument 2 must be gtk.gdk.Image,
not None

The graph zooms, but I don't see the rubberband. I got same
error in 1.0:

TypeError: Gdk.Drawable.draw_image() argument 2 must be gtk.gdk.Image,
not None

It uses a ScrolledWindow.

Also, are you using backend_gtk or backend_gtkagg (and does it matter
for your problem?)

I use GTKAgg and it works. GTK doesn't.

If you could create a minimal example starting with
embedding_in_gtk3.py that replicates your problem, we're more likely
to be able to help.

I have added the example above with my changes. Zooming is the problem.

embedding_in_gtk3-problem.py (1.65 KB)

···

On Fri, 9 Jul 2010 19:37:56 -0500 John Hunter <jdh2358@...287...> wrote:

On Fri, Jul 9, 2010 at 3:10 PM, Preben Randhol <randhol@...3174...> > wrote:

backend_gtk has limitations that backend_gtkagg does not, although I don't know that your zooming problem should be one of them. Are you sure you *need* to use backend_gtk instead of backend_gtkagg?

Eric

···

On 07/11/2010 07:52 AM, Preben Randhol wrote:

Also, are you using backend_gtk or backend_gtkagg (and does it matter
for your problem?)

I use GTKAgg and it works. GTK doesn't.

But I am using gtkagg. I only tested backend_gtk because I was asked
to. gtkagg still has problem with zooming/panning

Preben

···

On Sun, 11 Jul 2010 13:39:05 -1000 Eric Firing <efiring@...202...> wrote:

On 07/11/2010 07:52 AM, Preben Randhol wrote:

>>
>> Also, are you using backend_gtk or backend_gtkagg (and does it
>> matter for your problem?)
>
> I use GTKAgg and it works. GTK doesn't.
>

backend_gtk has limitations that backend_gtkagg does not, although I
don't know that your zooming problem should be one of them. Are you
sure you *need* to use backend_gtk instead of backend_gtkagg?

Thanks for posting the example. This runs fine for me (I can pan,
zoom, zoom to rect, the zoom to rect rubberband is drawn). Here is my
version info; what do you have for same?

  johnh@...2715...:tmp> uname -a
  SunOS udesktop191 5.10 Generic_139556-08 i86pc i386 i86pc
j ohnh@...2715...:tmp> python -c 'import gtk; print gtk.pygtk_version'
  (2, 6, 0)

Also, if you know the persion of gtk you are running, that might help.

Finally, you say you are running mpl 1.0, but your traceback says

  "/usr/lib/pymodules/python2.6/matplotlib/backends/backend_gtk.py", line
  606, in idle_draw drawable.draw_image(gc, imageBack, 0, 0, *lastrect)
  TypeError: Gdk.Drawable.draw_image() argument 2 must be gtk.gdk.Image,
  not None

but line 606 in backend_gtk in mpl 1.0.0 is not what this traceback
says. Are you sure you are picking up the right version? I suggest
flushing all your matplotlib* files and dirs in site-packages and
doing a clean install, and then running your test script with
--verbose-debug so we can get a better look at what is happening.
Please post the output which is logged to the terminal.

JDH

···

On Sun, Jul 11, 2010 at 12:52 PM, Preben Randhol <randhol@...3174...> wrote:

If you could create a minimal example starting with
embedding_in_gtk3.py that replicates your problem, we're more likely
to be able to help.