Skip to content

Instantly share code, notes, and snippets.

@mehrtash
Created April 18, 2015 01:24
Show Gist options
  • Save mehrtash/352aa92f5ebf6f46f920 to your computer and use it in GitHub Desktop.
Save mehrtash/352aa92f5ebf6f46f920 to your computer and use it in GitHub Desktop.
lm = slicer.app.layoutManager()
rw = lm.sliceWidget('Red')
rv = rw.sliceView()
renderWindow = rv.renderWindow()
interactor = renderWindow.GetInteractor()
text = vtk.vtkTextActor()
text.SetInput('PREOP')
textProperty = text.GetTextProperty()
textProperty.SetFontSize(10)
textProperty.SetColor(1,0,0)
textProperty.SetBold(1)
text_representation = vtk.vtkTextRepresentation()
xsize = 0.15
ysize = 0.15
ypos = 0.05
text_representation.GetPositionCoordinate().SetValue(0.5-(0.5*xsize), ypos)
text_representation.GetPosition2Coordinate().SetValue(xsize, ysize)
text_widget = vtk.vtkTextWidget()
text_widget.SetRepresentation(text_representation)
text_widget.SetInteractor(interactor)
text_widget.SetTextActor(text)
text_widget.SelectableOff()
text_widget.On()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment