Created
January 9, 2020 15:56
-
-
Save GuillaumeFavelier/ee40c130b7bbf65e2877a0ef24b2d8eb to your computer and use it in GitHub Desktop.
Hack for vtkSliderWidget with multiple handles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyvista as pv | |
import vtk | |
def foo(bar): | |
pass | |
def disable_tube(slider): | |
tr = slider.GetEventTranslator() | |
tr.ClearEvents() | |
tr.SetTranslation(vtk.vtkCommand.LeftButtonPressEvent, | |
vtk.vtkWidgetEvent.Select) | |
tr.SetTranslation(vtk.vtkCommand.LeftButtonReleaseEvent, | |
vtk.vtkWidgetEvent.EndSelect) | |
tr.SetTranslation(vtk.vtkCommand.MouseMoveEvent, | |
vtk.vtkWidgetEvent.Move) | |
slider.SetAnimationModeToOff() | |
rng = [0, 1] | |
p = pv.Plotter() | |
a = p.add_slider_widget(foo, rng) | |
disable_tube(a) | |
a = a.GetRepresentation() | |
a.SetValue(0.25) | |
a.GetSliderProperty().SetColor(1, 0, 0) | |
b = p.add_slider_widget(foo, rng) | |
disable_tube(b) | |
b = b.GetRepresentation() | |
b.SetValue(0.5) | |
b.GetSliderProperty().SetColor(0, 1, 0) | |
b.GetTubeProperty().SetOpacity(0.0) | |
c = p.add_slider_widget(foo, rng) | |
disable_tube(c) | |
c = c.GetRepresentation() | |
c.SetValue(0.75) | |
c.GetSliderProperty().SetColor(0, 0, 1) | |
c.GetTubeProperty().SetOpacity(0.0) | |
p.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment