I thought for a bit longer and found something that works just right:
#!/usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk
import matplotlib
matplotlib.use('GTK')
from matplotlib.figure import Figure
from matplotlib.backends.backend_gtk import FigureCanvasGTK, NavigationToolbar
from Numeric import *
def close_app(widget, data=None):
""" A call back if the close window control is clicked."""
print "delete_event being handled"
gtk.main_quit() # gracefully end the application.
if __name__ == "__main__":
main_window = gtk.Window(gtk.WINDOW_TOPLEVEL)
# Connect the delete_event signal to a function to close the application.
main_window.connect( "delete_event", close_app)
main_window.show()
figure = Figure(figsize=(6,4), dpi=72)
axes = figure.add_subplot(111)
# This calls the imshow routine and builds an Axes instance for us.
axes.imshow( array([[2,4,5,5],[5,6,7,8],[7,6,5,7]]))
main_window.set_border_width(10)
figure_canvas = FigureCanvasGTK(figure)
nav_tool = NavigationToolbar(figure_canvas,main_window)
nav_tool.show()
figure_canvas.show()
vbox = gtk.VBox()
vbox.show()
vbox.pack_start(figure_canvas)
vbox.pack_start(nav_tool, False, False)
main_window.add(vbox)
gtk.main()
On Mon, Feb 27, 2006 at 11:47:57AM -0500, Jon Fox wrote:
> I'm trying to embed functionality similar to the pylab.imshow() feature
> in a gtk application, but my bony head can't find an example program where someone
> does this explicitly, and hunting in the pylab interface has been rather
> frustrating.
>
> I'm using the the more typical x-y plots in gtk apps aleady (thank you
> example writers), but the ability to show an colormapped 2d image with a
> color bar would be really great.
>
> Any takers?
>
> -- Jon
>
> --
> .*. Dr. Jon R. Fox
> ..* http://www.drfox.com
> *** jo...@dr...
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting language
> that extends applications into web and mobile media. Attend the live webcast
> and join the prime developer group breaking into this new coding territory!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
--
.*. Dr. Jon R. Fox
..* http://www.drfox.com
*** jo...@dr...