MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / set_active

Method set_active

lib/matplotlib/widgets.py:1932–1968  ·  view source on GitHub ↗

Select button with number *index*. Callbacks will be triggered if :attr:`!eventson` is True. Parameters ---------- index : int The index of the button to activate. Raises ------ ValueError If the index is inv

(self, index)

Source from the content-addressed store, hash-verified

1930 self.set_radio_props({'facecolor': activecolor})
1931
1932 def set_active(self, index):
1933 """
1934 Select button with number *index*.
1935
1936 Callbacks will be triggered if :attr:`!eventson` is True.
1937
1938 Parameters
1939 ----------
1940 index : int
1941 The index of the button to activate.
1942
1943 Raises
1944 ------
1945 ValueError
1946 If the index is invalid.
1947 """
1948 if index not in range(len(self.labels)):
1949 raise ValueError(f'Invalid RadioButton index: {index}')
1950 self.value_selected = self.labels[index].get_text()
1951 self.index_selected = index
1952 button_facecolors = self._buttons.get_facecolor()
1953 button_facecolors[:] = colors.to_rgba("none")
1954 button_facecolors[index] = colors.to_rgba(self._active_colors[index])
1955 self._buttons.set_facecolor(button_facecolors)
1956
1957 if self.drawon:
1958 if self._useblit and self.canvas.supports_blit:
1959 background = self._load_blit_background()
1960 if background is not None:
1961 self.canvas.restore_region(background)
1962 self.ax.draw_artist(self._buttons)
1963 self.canvas.blit(self.ax.bbox)
1964 else:
1965 self.canvas.draw()
1966
1967 if self.eventson:
1968 self._observers.process('clicked', self.labels[index].get_text())
1969
1970 def clear(self):
1971 """Reset the active button to the initially active one."""

Callers 2

clearMethod · 0.95
test_RadioButtonsFunction · 0.95

Calls 10

_load_blit_backgroundMethod · 0.80
processMethod · 0.80
get_textMethod · 0.45
get_facecolorMethod · 0.45
to_rgbaMethod · 0.45
set_facecolorMethod · 0.45
restore_regionMethod · 0.45
draw_artistMethod · 0.45
blitMethod · 0.45
drawMethod · 0.45

Tested by 1

test_RadioButtonsFunction · 0.76