Skip to content

Commit

Permalink
Merge pull request matplotlib#1098 from efiring/suppress_closing_exce…
Browse files Browse the repository at this point in the history
…ption

suppress exception upon quitting with qt4agg on osx
  • Loading branch information
efiring committed Aug 29, 2012
2 parents 9aab0be + 9520d9f commit cf7618c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/matplotlib/backend_bases.py
Expand Up @@ -1599,11 +1599,13 @@ def close_event(self, guiEvent=None):
try:
event = CloseEvent(s, self, guiEvent=guiEvent)
self.callbacks.process(s, event)
except TypeError:
except (TypeError, AttributeError):
pass
# Suppress the TypeError when the python session is being killed.
# It may be that a better solution would be a mechanism to
# disconnect all callbacks upon shutdown.
# AttributeError occurs on OSX with qt4agg upon exiting
# with an open window; 'callbacks' attribute no longer exists.

def key_press_event(self, key, guiEvent=None):
"""
Expand Down Expand Up @@ -2423,12 +2425,12 @@ def __init__(self, canvas, num):
self.key_press)
"""
The returned id from connecting the default key handler via :meth:`FigureCanvasBase.mpl_connnect`.
To disable default key press handling::
manager, canvas = figure.canvas.manager, figure.canvas
canvas.mpl_disconnect(manager.key_press_handler_id)
"""

def destroy(self):
Expand Down

0 comments on commit cf7618c

Please sign in to comment.