Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit def8e73

Browse files
committed
DOC: Improve widgets API documentation
- Structure the page into widgets and helpers. This requires explicit listing of the classes, but is bearable as we don't often add new classes - Limit the inheritance diagram to the Widget subclasses instead of also showning the helper classes there - Add documentation for `_SelectorWidget`. It's important to understand its subclasses. This also results in correctly showing the selector inheritance in the inheritance diagram
1 parent ea0fb5b commit def8e73

2 files changed

Lines changed: 67 additions & 13 deletions

File tree

doc/api/widgets_api.rst

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,53 @@
22
``matplotlib.widgets``
33
**********************
44

5-
.. inheritance-diagram:: matplotlib.widgets
5+
.. currentmodule:: matplotlib.widgets
6+
7+
.. automodule:: matplotlib.widgets
8+
:no-members:
9+
:no-undoc-members:
10+
11+
12+
Widget classes
13+
==============
14+
15+
.. inheritance-diagram:: matplotlib.widgets.Widget
616
:parts: 1
17+
:private-bases:
18+
:include-subclasses:
719

20+
.. autosummary::
21+
:toctree: _as_gen
22+
:template: autosummary.rst
23+
:nosignatures:
824

9-
.. automodule:: matplotlib.widgets
10-
:members:
11-
:undoc-members:
12-
:show-inheritance:
25+
Widget
26+
AxesWidget
27+
Cursor
28+
MultiCursor
29+
Button
30+
CheckButtons
31+
RadioButtons
32+
SliderBase
33+
Slider
34+
RangeSlider
35+
TextBox
36+
_SelectorWidget
37+
RectangleSelector
38+
EllipseSelector
39+
Lasso
40+
LassoSelector
41+
PolygonSelector
42+
SpanSelector
43+
SubplotTool
44+
45+
Helper classes
46+
==============
47+
48+
.. autosummary::
49+
:toctree: _as_gen
50+
:nosignatures:
51+
52+
LockDraw
53+
ToolHandles
54+
ToolLineHandles

lib/matplotlib/widgets.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
"""
2-
GUI neutral widgets
3-
===================
4-
52
Widgets that are designed to work for any of the GUI backends.
3+
64
All of these widgets require you to predefine an `~.axes.Axes`
75
instance and pass that as the first parameter. Matplotlib doesn't try to
86
be too smart with respect to layout -- you will have to figure out how
@@ -2193,6 +2191,16 @@ def onmove(self, event):
21932191

21942192

21952193
class _SelectorWidget(AxesWidget):
2194+
"""
2195+
The base class for selector widgets.
2196+
2197+
This class provides common functionality for selector widgets,
2198+
such as handling mouse and keyboard events, managing state modifier keys, etc.
2199+
2200+
The class itself is private and may be changed or removed without prior warning.
2201+
However, the public API it provides to subclasses is stable and considered
2202+
public on the subclasses.
2203+
"""
21962204

21972205
def __init__(self, ax, onselect=None, useblit=False, button=None,
21982206
state_modifier_keys=None, use_data_coordinates=False):
@@ -2497,7 +2505,7 @@ def set_props(self, **props):
24972505
def set_handle_props(self, **handle_props):
24982506
"""
24992507
Set the properties of the handles selector artist. See the
2500-
`handle_props` argument in the selector docstring to know which
2508+
*handle_props* argument in the selector docstring to know which
25012509
properties are supported.
25022510
"""
25032511
if not hasattr(self, '_handles_artists'):
@@ -2521,13 +2529,15 @@ def _validate_state(self, state):
25212529
def add_state(self, state):
25222530
"""
25232531
Add a state to define the widget's behavior. See the
2524-
`state_modifier_keys` parameters for details.
2532+
*state_modifier_keys* parameter in the constructor of the concrete
2533+
selector class for details.
25252534
25262535
Parameters
25272536
----------
25282537
state : str
25292538
Must be a supported state of the selector. See the
2530-
`state_modifier_keys` parameters for details.
2539+
*state_modifier_keys* parameter in the constructor of the concrete
2540+
selector class for details.
25312541
25322542
Raises
25332543
------
@@ -2541,13 +2551,15 @@ def add_state(self, state):
25412551
def remove_state(self, state):
25422552
"""
25432553
Remove a state to define the widget's behavior. See the
2544-
`state_modifier_keys` parameters for details.
2554+
*state_modifier_keys* parameter in the constructor of the concrete
2555+
selector class for details.
25452556
25462557
Parameters
25472558
----------
25482559
state : str
25492560
Must be a supported state of the selector. See the
2550-
`state_modifier_keys` parameters for details.
2561+
*state_modifier_keys* parameter in the constructor of the concrete
2562+
selector class for details.
25512563
25522564
Raises
25532565
------

0 commit comments

Comments
 (0)