Move widget.{get,set}_active to AxisWidget.

The method was previously defined only for RectangleSelectors (#3375).

Also, an redundant line was removed (RectangleSelectors are already set
active on __init__ by the superclass).
I personally prefer the decorator form, but usually that implies that the
setter and/or getter is doing something non-trivial. The functional form is
nice for trivial setting/getting and can even be used in a templating-ish
fashion.


On Mon, Aug 18, 2014 at 4:48 AM, Eric Firing <notifications@github.com>
wrote:

> In lib/matplotlib/widgets.py:
>
> > @@ -111,6 +111,18 @@ def disconnect_events(self):
> >          for c in self.cids:
> >              self.canvas.mpl_disconnect(c)
> >
> > +    def set_active(self, active):
> > +        """Set whether the widget is active.
> > +        """
> > +        self._active = active
> > +
> > +    def get_active(self):
> > +        """Get whether the widget is active.
> > +        """
> > +        return self._active
> > +
> > +    active = property(set_active, get_active, doc="Is the widget active?")
>
> On 2014/08/17, 10:41 AM, Thomas A Caswell wrote: In
> lib/matplotlib/widgets.py: > @@ -111,6 +111,18 @@ def
> disconnect_events(self): > for c in self.cids: >
> self.canvas.mpl_disconnect(c) > > + def set_active(self, active): > +
> """Set whether the widget is active. > + """ > + self._active = active > +
> > + def get_active(self): > + """Get whether the widget is active. > + """
> > + return self._active > + > + active = property(set_active, get_active,
> doc="Is the widget active?") @mdboom <https://github.com/mdboom> <
> https://github.com/mdboom> @efiring <https://github.com/efiring> <
> https://github.com/efiring> Do we have a style preference on using this
> method or the decorators?
> I don't think this has been discussed. The majority of existing properties
> use the function form. Eric
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/matplotlib/matplotlib/pull/3376/files#r16342384>.
>