(self, ax, orientation, closedmin, closedmax,
valmin, valmax, valfmt, dragging, valstep)
| 309 | For the slider to remain responsive you must maintain a reference to it. |
| 310 | """ |
| 311 | def __init__(self, ax, orientation, closedmin, closedmax, |
| 312 | valmin, valmax, valfmt, dragging, valstep): |
| 313 | if ax.name == '3d': |
| 314 | raise ValueError('Sliders cannot be added to 3D Axes') |
| 315 | |
| 316 | super().__init__(ax) |
| 317 | _api.check_in_list(['horizontal', 'vertical'], orientation=orientation) |
| 318 | |
| 319 | self.orientation = orientation |
| 320 | self.closedmin = closedmin |
| 321 | self.closedmax = closedmax |
| 322 | self.valmin = valmin |
| 323 | self.valmax = valmax |
| 324 | self.valstep = valstep |
| 325 | self.drag_active = False |
| 326 | self.valfmt = valfmt |
| 327 | |
| 328 | if orientation == "vertical": |
| 329 | ax.set_ylim(valmin, valmax) |
| 330 | axis = ax.yaxis |
| 331 | else: |
| 332 | ax.set_xlim(valmin, valmax) |
| 333 | axis = ax.xaxis |
| 334 | |
| 335 | self._fmt = axis.get_major_formatter() |
| 336 | if not isinstance(self._fmt, ticker.ScalarFormatter): |
| 337 | self._fmt = ticker.ScalarFormatter() |
| 338 | self._fmt.set_axis(axis) |
| 339 | self._fmt.set_useOffset(False) # No additive offset. |
| 340 | self._fmt.set_useMathText(True) # x sign before multiplicative offset. |
| 341 | |
| 342 | ax.set_axis_off() |
| 343 | ax.set_navigate(False) |
| 344 | |
| 345 | self.connect_event("button_press_event", self._update) |
| 346 | self.connect_event("button_release_event", self._update) |
| 347 | if dragging: |
| 348 | self.connect_event("motion_notify_event", self._update) |
| 349 | self._observers = cbook.CallbackRegistry(signals=["changed"]) |
| 350 | |
| 351 | def _stepped_value(self, val): |
| 352 | """Return *val* coerced to closest number in the ``valstep`` grid.""" |
nothing calls this directly
no test coverage detected