@@ -2446,20 +2446,53 @@ def button_press_handler(event, canvas, toolbar=None):
2446
2446
2447
2447
2448
2448
class NonGuiException (Exception ):
2449
+ """Raised when trying show a figure in a non-GUI backend."""
2449
2450
pass
2450
2451
2451
2452
2452
2453
class FigureManagerBase (object ):
2453
2454
"""
2454
- Helper class for pyplot mode, wraps everything up into a neat bundle
2455
+ A backend-independent abstraction of a figure container and controller.
2456
+
2457
+ The figure manager is used by pyplot to interact with the window in a
2458
+ backend-independent way. It's an adapter for the real (GUI) framework that
2459
+ represents the visual figure on screen.
2460
+
2461
+ GUI backends define from this class to translate common operations such
2462
+ as *show* or *resize* to the GUI-specific code. Non-GUI backends do not
2463
+ support these operations an can just use the base class.
2464
+
2465
+ This following basic operations are accessible:
2466
+
2467
+ **Window operations**
2468
+
2469
+ - `~.FigureManagerBase.show`
2470
+ - `~.FigureManagerBase.destroy`
2471
+ - `~.FigureManagerBase.full_screen_toggle`
2472
+ - `~.FigureManagerBase.resize`
2473
+ - `~.FigureManagerBase.get_window_title`
2474
+ - `~.FigureManagerBase.set_window_title`
2475
+
2476
+ **Key and mouse button press handling**
2477
+
2478
+ The figure manager sets up default key and mouse button press handling by
2479
+ hooking up the `.key_press_handler` to the matplotlib event system. This
2480
+ ensures the same shortcuts and mouse actions across backends.
2481
+
2482
+ **Other operations**
2483
+
2484
+ Subclasses will have additional attributes and functions to access
2485
+ additional functionality. This is of course backend-specific. For example,
2486
+ most GUI backends have ``window`` and ``toolbar`` attributes that give
2487
+ access to the native GUI widgets of the respective framework.
2455
2488
2456
2489
Attributes
2457
2490
----------
2458
2491
canvas : :class:`FigureCanvasBase`
2459
- The backend-specific canvas instance
2492
+ The backend-specific canvas instance.
2460
2493
2461
2494
num : int or str
2462
- The figure number
2495
+ The figure number.
2463
2496
2464
2497
key_press_handler_id : int
2465
2498
The default key handler cid, when using the toolmanager.
@@ -2474,7 +2507,6 @@ class FigureManagerBase(object):
2474
2507
2475
2508
figure.canvas.mpl_disconnect(
2476
2509
figure.canvas.manager.button_press_handler_id)
2477
-
2478
2510
"""
2479
2511
def __init__ (self , canvas , num ):
2480
2512
self .canvas = canvas
@@ -2516,20 +2548,18 @@ def full_screen_toggle(self):
2516
2548
pass
2517
2549
2518
2550
def resize (self , w , h ):
2519
- """" For GUI backends, resize the window (in pixels)."""
2551
+ """For GUI backends, resize the window (in pixels)."""
2520
2552
2521
2553
def key_press (self , event ):
2522
2554
"""
2523
2555
Implement the default mpl key bindings defined at
2524
- :ref:`key-event-handling`
2556
+ :ref:`key-event-handling`.
2525
2557
"""
2526
2558
if rcParams ['toolbar' ] != 'toolmanager' :
2527
2559
key_press_handler (event , self .canvas , self .canvas .toolbar )
2528
2560
2529
2561
def button_press (self , event ):
2530
- """
2531
- The default Matplotlib button actions for extra mouse buttons.
2532
- """
2562
+ """The default Matplotlib button actions for extra mouse buttons."""
2533
2563
if rcParams ['toolbar' ] != 'toolmanager' :
2534
2564
button_press_handler (event , self .canvas , self .canvas .toolbar )
2535
2565
0 commit comments