Create a selector in *ax*. When a selection is made, clear the span and call onselect with:: onselect(pos_1, pos_2) and clear the drawn box/line. The ``pos_1`` and ``pos_2`` are arrays of length 2 containing the x- and y-coordinate. If *minspanx
(self, ax, onselect, drawtype='box',
minspanx=None, minspany=None, useblit=False,
lineprops=None, rectprops=None, spancoords='data',
button=None, maxdist=10, marker_props=None,
interactive=False, state_modifier_keys=None)
| 1987 | _shape_klass = Rectangle |
| 1988 | |
| 1989 | def __init__(self, ax, onselect, drawtype='box', |
| 1990 | minspanx=None, minspany=None, useblit=False, |
| 1991 | lineprops=None, rectprops=None, spancoords='data', |
| 1992 | button=None, maxdist=10, marker_props=None, |
| 1993 | interactive=False, state_modifier_keys=None): |
| 1994 | |
| 1995 | """ |
| 1996 | Create a selector in *ax*. When a selection is made, clear |
| 1997 | the span and call onselect with:: |
| 1998 | |
| 1999 | onselect(pos_1, pos_2) |
| 2000 | |
| 2001 | and clear the drawn box/line. The ``pos_1`` and ``pos_2`` are |
| 2002 | arrays of length 2 containing the x- and y-coordinate. |
| 2003 | |
| 2004 | If *minspanx* is not *None* then events smaller than *minspanx* |
| 2005 | in x direction are ignored (it's the same for y). |
| 2006 | |
| 2007 | The rectangle is drawn with *rectprops*; default:: |
| 2008 | |
| 2009 | rectprops = dict(facecolor='red', edgecolor = 'black', |
| 2010 | alpha=0.2, fill=True) |
| 2011 | |
| 2012 | The line is drawn with *lineprops*; default:: |
| 2013 | |
| 2014 | lineprops = dict(color='black', linestyle='-', |
| 2015 | linewidth = 2, alpha=0.5) |
| 2016 | |
| 2017 | Use *drawtype* if you want the mouse to draw a line, |
| 2018 | a box or nothing between click and actual position by setting |
| 2019 | |
| 2020 | ``drawtype = 'line'``, ``drawtype='box'`` or ``drawtype = 'none'``. |
| 2021 | Drawing a line would result in a line from vertex A to vertex C in |
| 2022 | a rectangle ABCD. |
| 2023 | |
| 2024 | *spancoords* is one of 'data' or 'pixels'. If 'data', *minspanx* |
| 2025 | and *minspanx* will be interpreted in the same coordinates as |
| 2026 | the x and y axis. If 'pixels', they are in pixels. |
| 2027 | |
| 2028 | *button* is a list of integers indicating which mouse buttons should |
| 2029 | be used for rectangle selection. You can also specify a single |
| 2030 | integer if only a single button is desired. Default is *None*, |
| 2031 | which does not limit which button can be used. |
| 2032 | |
| 2033 | Note, typically: |
| 2034 | 1 = left mouse button |
| 2035 | 2 = center mouse button (scroll wheel) |
| 2036 | 3 = right mouse button |
| 2037 | |
| 2038 | *interactive* will draw a set of handles and allow you interact |
| 2039 | with the widget after it is drawn. |
| 2040 | |
| 2041 | *state_modifier_keys* are keyboard modifiers that affect the behavior |
| 2042 | of the widget. |
| 2043 | |
| 2044 | The defaults are: |
| 2045 | dict(move=' ', clear='escape', square='shift', center='ctrl') |
| 2046 |