8000 Use `super()` in widget classes and examples. · matplotlib/matplotlib@9617ea7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9617ea7

Browse files
committed
Use super() in widget classes and examples.
1 parent 7b574c3 commit 9617ea7

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

examples/widgets/menu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class MenuItem(artist.Artist):
3232

3333
def __init__(self, fig, labelstr, props=None, hoverprops=None,
3434
on_select=None):
35-
artist.Artist.__init__(self)
35+
super().__init__()
3636

3737
self.set_figure(fig)
3838
self.labelstr = labelstr

lib/matplotlib/widgets.py

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def __init__(self, ax, label, image=None,
166166
hovercolor : color
167167
The color of the button when the mouse is over it.
168168
"""
169-
AxesWidget.__init__(self, ax)
169+
super().__init__(ax)
170170

171171
if image is not None:
172172
ax.imshow(image)
@@ -308,7 +308,7 @@ def __init__(self, ax, label, valmin, valmax, valinit=0.5, valfmt=None,
308308
if ax.name == '3d':
309309
raise ValueError('Sliders cannot be added to 3D Axes')
310310

311-
AxesWidget.__init__(self, ax)
311+
super().__init__(ax)
312312

313313
if slidermin is not None and not hasattr(slidermin, 'val'):
314314
raise ValueError("Argument slidermin ({}) has no 'val'"
@@ -552,7 +552,7 @@ def __init__(self, ax, labels, actives=None):
552552
The initial check states of the buttons. The list must have the
553553
same length as *labels*. If not given, all buttons are unchecked.
554554
"""
555-
AxesWidget.__init__(self, ax)
555+
super().__init__(ax)
556556

557557
ax.set_xticks([])
558558
ax.set_yticks([])
@@ -715,7 +715,7 @@ def __init__(self, ax, label, initial='',
715715
label_pad : float
716716
The distance between the label and the right side of the textbox.
717717
"""
718-
AxesWidget.__init__(self, ax)
718+
super().__init__(ax)
719719

720720
self.DIST_FROM_LEFT = .05
721721

@@ -983,7 +983,7 @@ def __init__(self, ax, labels, active=0, activecolor='blue'):
983983
activecolor : color
984984
The color of the selected button.
985985
"""
986-
AxesWidget.__init__(self, ax)
986+
super().__init__(ax)
987987
self.activecolor = activecolor
988988
self.value_selected = None
989989

@@ -1236,7 +1236,7 @@ class Cursor(AxesWidget):
12361236

12371237
def __init__(self, ax, horizOn=True, vertOn=True, useblit=False,
12381238
**lineprops):
1239-
AxesWidget.__init__(self, ax)
1239+
super().__init__(ax)
12401240

12411241
self.connect_event('motion_notify_event', self.onmove)
12421242
self.connect_event('draw_event', self.clear)
@@ -1418,7 +1418,7 @@ class _SelectorWidget(AxesWidget):
14181418

14191419
def __init__(self, ax, onselect, useblit=False, button=None,
14201420
state_modifier_keys=None):
1421-
AxesWidget.__init__(self, ax)
1421+
super().__init__(ax)
14221422

14231423
self.visible = True
14241424
self.onselect = onselect
@@ -1445,7 +1445,7 @@ def __init__(self, ax, onselect, useblit=False, button=None,
14451445
self.state = set()
14461446

14471447
def set_active(self, active):
1448-
AxesWidget.set_active(self, active)
1448+
super().set_active(active)
14491449
if active:
14501450
self.update_background(None)
14511451

@@ -1676,8 +1676,7 @@ def __init__(self, ax, onselect, direction, minspan=None, useblit=False,
16761676
rectprops=None, onmove_callback=None, span_stays=False,
16771677
button=None):
16781678

1679-
_SelectorWidget.__init__(self, ax, onselect, useblit=useblit,
1680-
button=button)
1679+
super().__init__(ax, onselect, useblit=useblit, button=button)
16811680

16821681
if rectprops is None:
16831682
rectprops = dict(facecolor='red', alpha=0.5)
@@ -1737,7 +1736,7 @@ def new_axes(self, ax):
17371736

17381737
def ignore(self, event):
17391738
# docstring inherited
1740-
return _SelectorWidget.ignore(self, event) or not self.visible
1739+
return super().ignore(event) or not self.visible
17411740

17421741
def _press(self, event):
17431742
"""on button press event"""
@@ -1980,9 +1979,8 @@ def onselect(eclick: MouseEvent, erelease: MouseEvent)
19801979
19811980
"square" and "center" can be combined.
19821981
"""
1983-
_SelectorWidget.__init__(self, ax, onselect, useblit=useblit,
1984-
button=button,
1985-
state_modifier_keys=state_modifier_keys)
1982+
super().__init__(ax, onselect, useblit=useblit, button=button,
1983+
state_modifier_keys=state_modifier_keys)
19861984

19871985
self.to_draw = None
19881986
self.visible = True
@@ -2401,8 +2399,7 @@ def onselect(verts):
24012399

24022400
def __init__(self, ax, onselect=None, useblit=True, lineprops=None,
24032401
button=None):
2404-
_SelectorWidget.__init__(self, ax, onselect, useblit=useblit,
2405-
button=button)
2402+
super().__init__(ax, onselect, useblit=useblit, button=button)
24062403
self.verts = None
24072404
if lineprops is None:
24082405
lineprops = dict()
@@ -2488,8 +2485,8 @@ def __init__(self, ax, onselect, useblit=False,
24882485
move_all='shift', move='not-applicable',
24892486
square='not-applicable',
24902487
center='not-applicable')
2491-
_SelectorWidget.__init__(self, ax, onselect, useblit=useblit,
2492-
state_modifier_keys=state_modifier_keys)
2488+
super().__init__(ax, onselect, useblit=useblit,
2489+
state_modifier_keys=state_modifier_keys)
24932490

24942491
self._xs, self._ys = [0], [0]
24952492
self._polygon_completed = False
@@ -2666,7 +2663,7 @@ class Lasso(AxesWidget):
26662663
"""
26672664

26682665
def __init__(self, ax, xy, callback=None, useblit=True):
2669-
AxesWidget.__init__(self, ax)
2666+
super().__init__(ax)
26702667

26712668
self.useblit = useblit and self.canvas.supports_blit
26722669
if self.useblit:

0 commit comments

Comments
 (0)
0