I almost have a solution for this for the Mac OS X backend. I am stuck though at what I should pass to enter_notify_event and leave_notify_event for the guiEvent:
def leave_notify_event(self, guiEvent=None): """ Backend derived classes should call this function when leaving canvas *guiEvent* the native UI event that generated the mpl event """ What are the requirements for guiEvent? If I call leave_notify_event without guiEvent, so guiEvent = None, then the example gives me the following error: enter_figure Figure(640x480) leave_figure Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/backend_bases.py", line 1416, in leave_notify_event self.callbacks.process('figure_leave_event', LocationEvent.lastevent) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/cbook.py", line 169, in process func(*args, **kwargs) File "test.py", line 23, in leave_figure print 'leave_figure', event.canvas.figure AttributeError: 'NoneType' object has no attribute 'canvas' So I guess I should pass some type of event object to enter|leave_notify_event. --Michiel. --- On Sun, 2/14/10, David Arnold <dwarnol...@suddenlink.net> wrote: > From: David Arnold <dwarnol...@suddenlink.net> > Subject: Re: [Matplotlib-users] Enter Figure on Macs > To: "John Hunter" <jdh2...@gmail.com> > Cc: "Michiel de Hoon" <mjldeh...@yahoo.com>, > matplotlib-users@lists.sourceforge.net > Date: Sunday, February 14, 2010, 11:50 PM > John, > > Only the wxagg worked. Here is the output: > > $HOME=/Users/darnold > CONFIGDIR=/Users/darnold/.matplotlib > matplotlib data path > /Library/Frameworks/Python.framework/Versions/6.0.0/lib/python2.6/site-packages/matplotlib/mpl-data > loaded rc file /Users/darnold/.matplotlib/matplotlibrc > matplotlib version 0.99.1.1 > verbose.level helpful > interactive is False > units is False > platform is darwin > Using fontManager instance from > /Users/darnold/.matplotlib/fontList.cache > backend WXAgg version 2.8.10.1 > findfont: Matching > :family=sans-serif:style=normal:variant=normal:weight=normal:stretch=normal:size=medium > to Bitstream Vera Sans > (/Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib-0.98.5.2n2-py2.5-macosx-10.3-fat.egg/matplotlib/mpl-data/fonts/ttf/Vera.ttf) > with score of 0.000000 > findfont: Matching > :family=sans-serif:style=normal:variant=normal:weight=normal:stretch=normal:size=12.0 > to Bitstream Vera Sans > (/Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib-0.98.5.2n2-py2.5-macosx-10.3-fat.egg/matplotlib/mpl-data/fonts/ttf/Vera.ttf) > with score of 0.000000 > enter_figure Figure(640x480) > leave_figure Figure(640x480) > enter_figure Figure(640x480) > leave_figure Figure(640x480) > enter_figure Figure(640x480) > leave_figure Figure(640x480) > enter_figure Figure(640x480) > enter_axes Axes(0.125,0.536364;0.775x0.363636) > leave_axes Axes(0.125,0.536364;0.775x0.363636) > enter_axes Axes(0.125,0.1;0.775x0.363636) > leave_axes Axes(0.125,0.1;0.775x0.363636) > leave_figure Figure(640x480) > > > Did not work with macosx: > > $HOME=/Users/darnold > CONFIGDIR=/Users/darnold/.matplotlib > matplotlib data path > /Library/Frameworks/Python.framework/Versions/6.0.0/lib/python2.6/site-packages/matplotlib/mpl-data > loaded rc file /Users/darnold/.matplotlib/matplotlibrc > matplotlib version 0.99.1.1 > verbose.level helpful > interactive is False > units is False > platform is darwin > Using fontManager instance from > /Users/darnold/.matplotlib/fontList.cache > backend MacOSX version unknown > enter_axes Axes(0.125,0.536364;0.775x0.363636) > leave_axes Axes(0.125,0.536364;0.775x0.363636) > enter_axes Axes(0.125,0.1;0.775x0.363636) > leave_axes Axes(0.125,0.1;0.775x0.363636) > enter_axes Axes(0.125,0.1;0.775x0.363636) > leave_axes Axes(0.125,0.1;0.775x0.363636) > enter_axes Axes(0.125,0.536364;0.775x0.363636) > leave_axes Axes(0.125,0.536364;0.775x0.363636) > enter_axes Axes(0.125,0.1;0.775x0.363636) > leave_axes Axes(0.125,0.1;0.775x0.363636) > > > Did not work with tkagg: > > $HOME=/Users/darnold > CONFIGDIR=/Users/darnold/.matplotlib > matplotlib data path > /Library/Frameworks/Python.framework/Versions/6.0.0/lib/python2.6/site-packages/matplotlib/mpl-data > loaded rc file /Users/darnold/.matplotlib/matplotlibrc > matplotlib version 0.99.1.1 > verbose.level helpful > interactive is False > units is False > platform is darwin > Using fontManager instance from > /Users/darnold/.matplotlib/fontList.cache > backend TkAgg version 8.4 > findfont: Matching > :family=sans-serif:style=normal:variant=normal:weight=normal:stretch=normal:size=medium > to Bitstream Vera Sans > (/Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib-0.98.5.2n2-py2.5-macosx-10.3-fat.egg/matplotlib/mpl-data/fonts/ttf/Vera.ttf) > with score of 0.000000 > findfont: Matching > :family=sans-serif:style=normal:variant=normal:weight=normal:stretch=normal:size=12.0 > to Bitstream Vera Sans > (/Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib-0.98.5.2n2-py2.5-macosx-10.3-fat.egg/matplotlib/mpl-data/fonts/ttf/Vera.ttf) > with score of 0.000000 > enter_axes Axes(0.125,0.536364;0.775x0.363636) > leave_axes Axes(0.125,0.536364;0.775x0.363636) > enter_axes Axes(0.125,0.1;0.775x0.363636) > leave_axes Axes(0.125,0.1;0.775x0.363636) > enter_axes Axes(0.125,0.536364;0.775x0.363636) > leave_axes Axes(0.125,0.536364;0.775x0.363636) > enter_axes Axes(0.125,0.1;0.775x0.363636) > leave_axes Axes(0.125,0.1;0.775x0.363636) > > > > On Feb 14, 2010, at 7:50 PM, John Hunter wrote: > > > On Sun, Feb 14, 2010 at 6:53 PM, David Arnold <dwarnol...@suddenlink.net> > wrote: > >> All, > >> > >> Any Mac users out there? This script from the User > Guide does not seem to recognize entering or leaving a > figure. Any thoughts? > > > > My Mac is currently dead, but I developed these events > while I was a > > mac user and so am pretty sure they worked. It > is more likely a > > specific backend problem than a Mac vs non-Mac problem > (eg it may be > > specific to the macosx backend but not a problem for > macs in general) > > > > http://matplotlib.sourceforge.net/faq/installing_faq.html#what-is-a-backend > > > > Could you try running the script with the "use" > directive at the top > > of your script (before any other mpl code) for > different backends, eg > > tkagg vs macosx vs wxagg > > > > import matplotlib > > matplotlib.use('tkagg') # and also try > macosx and wxagg > > > > so we can see exactly where the problem is > arising. Also, run your > > script with --verbose-helpful and report the debugging > output. > > Looking at the code, it appears the enter_notify_event > and > > leave_notify_event are only defined for wx, qt and gtk > currently, and > > so need to be implemented for tk and macosx. > > > > JDH > > ------------------------------------------------------------------------------ SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users