@@ -2463,20 +2463,53 @@ def button_press_handler(event, canvas, toolbar=None):
2463
2463
2464
2464
2465
2465
class NonGuiException (Exception ):
2466
+ """Raised when trying show a figure in a non-GUI backend."""
2466
2467
pass
2467
2468
2468
2469
2469
2470
class FigureManagerBase :
2470
2471
"""
2471
- Helper class for pyplot mode, wraps everything up into a neat bundle.
2472
+ A backend-independent abstraction of a figure container and controller.
2473
+
2474
+ The figure manager is used by pyplot to interact with the window in a
2475
+ backend-independent way. It's an adapter for the real (GUI) framework that
2476
+ represents the visual figure on screen.
2477
+
2478
+ GUI backends define from this class to translate common operations such
2479
+ as *show* or *resize* to the GUI-specific code. Non-GUI backends do not
2480
+ support these operations an can just use the base class.
2481
+
2482
+ This following basic operations are accessible:
2483
+
2484
+ **Window operations**
2485
+
2486
+ - `~.FigureManagerBase.show`
2487
+ - `~.FigureManagerBase.destroy`
2488
+ - `~.FigureManagerBase.full_screen_toggle`
2489
+ - `~.FigureManagerBase.resize`
2490
+ - `~.FigureManagerBase.get_window_title`
2491
+ - `~.FigureManagerBase.set_window_title`
2492
+
2493
+ **Key and mouse button press handling**
2494
+
2495
+ The figure manager sets up default key and mouse button press handling by
2496
+ hooking up the `.key_press_handler` to the matplotlib event system. This
2497
+ ensures the same shortcuts and mouse actions across backends.
2498
+
2499
+ **Other operations**
2500
+
2501
+ Subclasses will have additional attributes and functions to access
2502
+ additional functionality. This is of course backend-specific. For example,
2503
+ most GUI backends have ``window`` and ``toolbar`` attributes that give
2504
+ access to the native GUI widgets of the respective framework.
2472
2505
2473
2506
Attributes
2474
2507
----------
2475
2508
canvas : :class:`FigureCanvasBase`
2476
- The backend-specific canvas instance
2509
+ The backend-specific canvas instance.
2477
2510
2478
2511
num : int or str
2479
- The figure number
2512
+ The figure number.
2480
2513
2481
2514
key_press_handler_id : int
2482
2515
The default key handler cid, when using the toolmanager.
@@ -2491,7 +2524,6 @@ class FigureManagerBase:
2491
2524
2492
2525
figure.canvas.mpl_disconnect(
2493
2526
figure.canvas.manager.button_press_handler_id)
2494
-
2495
2527
"""
2496
2528
def __init__ (self , canvas , num ):
2497
2529
self .canvas = canvas
@@ -2533,7 +2565,7 @@ def full_screen_toggle(self):
2533
2565
pass
2534
2566
2535
2567
def resize (self , w , h ):
2536
- """" For GUI backends, resize the window (in pixels)."""
2568
+ """For GUI backends, resize the window (in pixels)."""
2537
2569
2538
2570
def key_press (self , event ):
2539
2571
"""
@@ -2544,9 +2576,7 @@ def key_press(self, event):
2544
2576
key_press_handler (event , self .canvas , self .canvas .toolbar )
2545
2577
2546
2578
def button_press (self , event ):
2547
- """
2548
- The default Matplotlib button actions for extra mouse buttons.
2549
- """
2579
+ """The default Matplotlib button actions for extra mouse buttons."""
2550
2580
if rcParams ['toolbar' ] != 'toolmanager' :
2551
2581
button_press_handler (event , self .canvas , self .canvas .toolbar )
2552
2582
0 commit comments