@@ -2470,20 +2470,53 @@ def button_press_handler(event, canvas, toolbar=None):
24702470
24712471
24722472class NonGuiException (Exception ):
2473+ """Raised when trying show a figure in a non-GUI backend."""
24732474 pass
24742475
24752476
24762477class FigureManagerBase :
24772478 """
2478- Helper class for pyplot mode, wraps everything up into a neat bundle.
2479+ A backend-independent abstraction of a figure container and controller.
2480+
2481+ The figure manager is used by pyplot to interact with the window in a
2482+ backend-independent way. It's an adapter for the real (GUI) framework that
2483+ represents the visual figure on screen.
2484+
2485+ GUI backends define from this class to translate common operations such
2486+ as *show* or *resize* to the GUI-specific code. Non-GUI backends do not
2487+ support these operations an can just use the base class.
2488+
2489+ This following basic operations are accessible:
2490+
2491+ **Window operations**
2492+
2493+ - `~.FigureManagerBase.show`
2494+ - `~.FigureManagerBase.destroy`
2495+ - `~.FigureManagerBase.full_screen_toggle`
2496+ - `~.FigureManagerBase.resize`
2497+ - `~.FigureManagerBase.get_window_title`
2498+ - `~.FigureManagerBase.set_window_title`
2499+
2500+ **Key and mouse button press handling**
2501+
2502+ The figure manager sets up default key and mouse button press handling by
2503+ hooking up the `.key_press_handler` to the matplotlib event system. This
2504+ ensures the same shortcuts and mouse actions across backends.
2505+
2506+ **Other operations**
2507+
2508+ Subclasses will have additional attributes and functions to access
2509+ additional functionality. This is of course backend-specific. For example,
2510+ most GUI backends have ``window`` and ``toolbar`` attributes that give
2511+ access to the native GUI widgets of the respective framework.
24792512
24802513 Attributes
24812514 ----------
24822515 canvas : :class:`FigureCanvasBase`
2483- The backend-specific canvas instance
2516+ The backend-specific canvas instance.
24842517
24852518 num : int or str
2486- The figure number
2519+ The figure number.
24872520
24882521 key_press_handler_id : int
24892522 The default key handler cid, when using the toolmanager.
@@ -2498,7 +2531,6 @@ class FigureManagerBase:
24982531
24992532 figure.canvas.mpl_disconnect(
25002533 figure.canvas.manager.button_press_handler_id)
2501-
25022534 """
25032535 def __init__ (self , canvas , num ):
25042536 self .canvas = canvas
@@ -2540,7 +2572,7 @@ def full_screen_toggle(self):
25402572 pass
25412573
25422574 def resize (self , w , h ):
2543- """" For GUI backends, resize the window (in pixels)."""
2575+ """For GUI backends, resize the window (in pixels)."""
25442576
25452577 def key_press (self , event ):
25462578 """
@@ -2551,9 +2583,7 @@ def key_press(self, event):
25512583 key_press_handler (event , self .canvas , self .canvas .toolbar )
25522584
25532585 def button_press (self , event ):
2554- """
2555- The default Matplotlib button actions for extra mouse buttons.
2556- """
2586+ """The default Matplotlib button actions for extra mouse buttons."""
25572587 if rcParams ['toolbar' ] != 'toolmanager' :
25582588 button_press_handler (event , self .canvas , self .canvas .toolbar )
25592589
0 commit comments