YSlider (hwx.gui)#

class YSlider(plot, value=0, marker=True, **kwds)#

Bases: Slider

A movable horizontal line

Attribute Table#

Name

Type

icon

str

value

property

y

property

Example

from hwx import gui
from hwx.gui.XyPlot import XyPlot
from hwx.gui.XyPlot import XSlider, YSlider

plot = XyPlot(title="Plot with Sliders")
x = [1, 2, 4, 5, 6]
y = [1, 3, 4, 1, 7]
plot.addCurve(x=x, y=y, draggable=False, label="Curve1")

xSlider = XSlider(plot, color="red", linestyle="dashed", value=1.0)
ySlider = YSlider(plot, color="red", linestyle="dashed", value=1.0)

# Show the mouse position in the slider text
class MyEventHandler:
def __init__(self, xSlider, ySlider):
   self.xSlider = xSlider
   self.ySlider = ySlider

def onMouseMove(self, event):
   self.xSlider.text = event.x
   self.ySlider.text = event.y
   return False

plot.addEventHandler(MyEventHandler(xSlider, ySlider))
show(plot)
property value#

The y value of the slider.

property y#

The y value of the slider.