@@ -2470,20 +2470,53 @@ def button_press_handler(event, canvas, toolbar=None):
2470
2470
2471
2471
2472
2472
class NonGuiException (Exception ):
2473
+ """Raised when trying show a figure in a non-GUI backend."""
2473
2474
pass
2474
2475
2475
2476
2476
2477
class FigureManagerBase :
2477
2478
"""
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.
2479
2512
2480
2513
Attributes
2481
2514
----------
2482
2515
canvas : :class:`FigureCanvasBase`
2483
- The backend-specific canvas instance
2516
+ The backend-specific canvas instance.
2484
2517
2485
2518
num : int or str
2486
- The figure number
2519
+ The figure number.
2487
2520
2488
2521
key_press_handler_id : int
2489
2522
The default key handler cid, when using the toolmanager.
@@ -2498,7 +2531,6 @@ class FigureManagerBase:
2498
2531
2499
2532
figure.canvas.mpl_disconnect(
2500
2533
figure.canvas.manager.button_press_handler_id)
2501
-
2502
2534
"""
2503
2535
def __init__ (self , canvas , num ):
2504
2536
self .canvas = canvas
@@ -2540,7 +2572,7 @@ def full_screen_toggle(self):
2540
2572
pass
2541
2573
2542
2574
def resize (self , w , h ):
2543
- """" For GUI backends, resize the window (in pixels)."""
2575
+ """For GUI backends, resize the window (in pixels)."""
2544
2576
2545
2577
def key_press (self , event ):
2546
2578
"""
@@ -2551,9 +2583,7 @@ def key_press(self, event):
2551
2583
key_press_handler (event , self .canvas , self .canvas .toolbar )
2552
2584
2553
2585
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."""
2557
2587
if rcParams ['toolbar' ] != 'toolmanager' :
2558
2588
button_press_handler (event , self .canvas , self .canvas .toolbar )
2559
2589
0 commit comments