can't interact with embedded gtk

The following works without the --pylab switch but not with it. The error I get is some how related to a call to get the active figure which returns None.

C:\Python26\lib\site-packages\mpl_toolkits\basemap_init_.pyc in set_axes_limi

ts(self, ax)

2531 if is_interactive():

2532 figManager = _pylab_helpers.Gcf.get_active()

-> 2533 figManager.canvas.draw()

AttributeError: ‘NoneType’ object has no attribute ‘canvas’.

In the following code. the error happens at

m.drawcoastlines()

Help?

···

===============================================

from mpl_toolkits.basemap import Basemap, shiftgrid

import numpy as np

import matplotlib.pyplot as plt

from matplotlib.backends.backend_gtkagg import \

FigureCanvasGTKAgg as FigureCanvas

import gtk

create new figure

#fig=plt.figure()

from matplotlib.figure import Figure

fig = Figure(figsize=(5,5), dpi=100)

canvas = FigureCanvas(fig)

window = gtk.Window(gtk.WINDOW_TOPLEVEL)

window.add(canvas)

setup cylindrical equidistant map projection (global domain).

ax = fig.add_axes([0.1,0.1,0.7,0.7])

m = Basemap(llcrnrlon=-180.,llcrnrlat=-90,urcrnrlon=180.,urcrnrlat=90.,\

resolution=‘c’,area_thresh=10000.,projection=‘cyl’,ax=ax)

m.drawcoastlines()

m.tissot(-117,34,10,10)

#plt.show()

canvas.show()

window.show()

I think the Figure you create may be not registered in the pylab
framework, and indeed I think this is not a bug. The --pylab switch
tries to obtain the active figure, but because there is no active
pyplot-Figure, it gets None from get_active() in your traceback. Then
it fails.

I think --pylab is only intended for pure pyplot usage, when you use
the oo framework, be prepared to make it fail.

Does this help?

Friedrich

2010/4/8 Mathew Yeates <mat.yeates@...287...>:

···

The following works without the --pylab switch but not with it. The error I
get is some how related to a call to get the active figure which returns
None.
C:\Python26\lib\site-packages\mpl_toolkits\basemap\__init__.pyc in
set_axes_limi
ts(self, ax)
2531 if is_interactive():
2532 figManager = _pylab_helpers.Gcf.get_active()
-> 2533 figManager.canvas.draw()
AttributeError: 'NoneType' object has no attribute 'canvas'.
In the following code. the error happens at
m.drawcoastlines()
Help?

from mpl_toolkits.basemap import Basemap, shiftgrid
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.backends.backend_gtkagg import \
FigureCanvasGTKAgg as FigureCanvas
import gtk
# create new figure
#fig=plt.figure()
from matplotlib.figure import Figure
fig = Figure(figsize=(5,5), dpi=100)
canvas = FigureCanvas(fig)
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.add(canvas)
# setup cylindrical equidistant map projection (global domain).
ax = fig.add_axes([0.1,0.1,0.7,0.7])
m = Basemap(llcrnrlon=-180.,llcrnrlat=-90,urcrnrlon=180.,urcrnrlat=90.,\
resolution='c',area_thresh=10000.,projection='cyl',ax=ax)
m.drawcoastlines()
m.tissot(-117,34,10,10)
#plt.show()
canvas.show()
window.show()