dipy/viz/widget.py
def text(iren, ren, callback, message="DIPY",
         left_down_pos=(0.8, 0.5), right_top_pos=(0.9, 0.5),
         color=(1., .5, .0), opacity=1., border=False):
    """ 2D text that can be clicked and process events

    Parameters
    ----------
    iren : vtkRenderWindowInteractor
        Used to process events and handle them to the button. Can also be given
        by the attribute ``ShowManager.iren``.
    ren :  vtkRenderer or Renderer
        Used to update the slider's position when the window changes. Can also
        be given by the ``ShowManager.ren`` attribute.
    callback : function
        Function that has at least ``obj`` and ``event`` as parameters. It will
        be called when the button is pressed.
    message : str
        Message to be shown in the text widget
    left_down_pos : tuple
        Normalized coordinates for left down corner of text. Default is
        (0.8, 0.5).
    right_top_pos : tuple
        Normalized coordinates for left down corner of text. Default is
        (0.9, 0.5).
    color : tuple
        Foreground RGB color of text. Default is (1., .5, .0).
    opacity : float
        Takes values from 0 to 1. Default is 1.
    border : bool
        Show text border. Default is False.

    Returns
    -------
    text : TextWidget
        This object inherits from ``vtkTextWidget`` has an additional method
        called ``place`` which allows to update the position of the text if
        necessary.
    """

    # Create the TextActor
    text_actor = vtk.vtkTextActor()
    text_actor.SetInput(message)
    text_actor.GetTextProperty().SetColor(color)
    text_actor.GetTextProperty().SetOpacity(opacity)

    # Create the text representation. Used for positioning the text_actor
    text_rep = vtk.vtkTextRepresentation()
    text_rep.SetPlaceFactor(1)

    text_rep.GetPositionCoordinate().SetCoordinateSystemToNormalizedDisplay()
    text_rep.GetPositionCoordinate().SetValue(*left_down_pos)

    text_rep.GetPosition2Coordinate().SetCoordinateSystemToNormalizedDisplay()
    text_rep.GetPosition2Coordinate().SetValue(*right_top_pos)

    if border:
        text_rep.SetShowBorderToOn()
    else:
        text_rep.SetShowBorderToOff()

    class TextWidget(vtk.vtkTextWidget):

        def place(self, renderer):

            text_rep = self.GetRepresentation()

            position = text_rep.GetPositionCoordinate()
            position.SetCoordinateSystemToNormalizedDisplay()
            position.SetValue(*left_down_pos)

            position2 = text_rep.GetPosition2Coordinate()
            position2.SetCoordinateSystemToNormalizedDisplay()
            position2.SetValue(*right_top_pos)

            self.SelectableOn()
            self.ResizableOff()
            text_rep.ProportionalResizeOn()

            self.On()

    text_widget = TextWidget()
    text_widget.SetRepresentation(text_rep)
    text_widget.SetInteractor(iren)
    text_widget.SetTextActor(text_actor)
    text_widget.SelectableOn()
    text_widget.ResizableOff()
    text_widget.GetRepresentation().ProportionalResizeOn()

    text_widget.AddObserver(vtk.vtkCommand.WidgetActivateEvent, callback)
    text_widget.On()

    # This is a hack for avoiding not plotting the text widget when
    # backface culling in On on a different actor
    ss = vtk.vtkSphereSource()
    mapper = vtk.vtkPolyDataMapper()
    mapper.SetInputConnection(ss.GetOutputPort())
    actor = vtk.vtkActor()
    actor.GetProperty().BackfaceCullingOff()

    return text_widget
 2D text that can be clicked and process events

    Parameters
    ----------
    iren : vtkRenderWindowInteractor
        Used to process events and handle them to the button. Can also be given
        by the attribute ``ShowManager.iren``.
    ren :  vtkRenderer or Renderer
        Used to update the slider's position when the window changes. Can also
        be given by the ``ShowManager.ren`` attribute.
    callback : function
        Function that has at least ``obj`` and ``event`` as parameters. It will
        be called when the button is pressed.
    message : str
        Message to be shown in the text widget
    left_down_pos : tuple
        Normalized coordinates for left down corner of text. Default is
        (0.8, 0.5).
    right_top_pos : tuple
        Normalized coordinates for left down corner of text. Default is
        (0.9, 0.5).
    color : tuple
        Foreground RGB color of text. Default is (1., .5, .0).
    opacity : float
        Takes values from 0 to 1. Default is 1.
    border : bool
        Show text border. Default is False.

    Returns
    -------
    text : TextWidget
        This object inherits from ``vtkTextWidget`` has an additional method
        called ``place`` which allows to update the position of the text if
        necessary.
    
2D text that can be clicked and process events
Parameters

iren : vtkRenderWindowInteractor
Used to process events and handle them to the button. Can also be given
by the attribute ``ShowManager.iren``.
ren :  vtkRenderer or Renderer
Used to update the slider's position when the window changes. Can also
be given by the ``ShowManager.ren`` attribute.

Returns


2D text that can be clicked and process events Parameters iren : vtkRenderWindowInteractor Used to process events and handle them to the button . Can also be given by the attribute ` ` ShowManager . iren ` ` . ren : vtkRenderer or Renderer Used to update the slider ' s position when the window changes . Can also be given by the ` ` ShowManager . ren ` ` attribute . Returns
def text(iren, ren, callback, message="DIPY",
         left_down_pos=(0.8, 0.5), right_top_pos=(0.9, 0.5),
         color=(1., .5, .0), opacity=1., border=False):
    text_actor = vtk.vtkTextActor()
    text_actor.SetInput(message)
    text_actor.GetTextProperty().SetColor(color)
    text_actor.GetTextProperty().SetOpacity(opacity)
    text_rep = vtk.vtkTextRepresentation()
    text_rep.SetPlaceFactor(1)
    text_rep.GetPositionCoordinate().SetCoordinateSystemToNormalizedDisplay()
    text_rep.GetPositionCoordinate().SetValue(*left_down_pos)
    text_rep.GetPosition2Coordinate().SetCoordinateSystemToNormalizedDisplay()
    text_rep.GetPosition2Coordinate().SetValue(*right_top_pos)
    if border:
        text_rep.SetShowBorderToOn()
    else:
        text_rep.SetShowBorderToOff()
    class TextWidget(vtk.vtkTextWidget):
        def place(self, renderer):
            text_rep = self.GetRepresentation()
            position = text_rep.GetPositionCoordinate()
            position.SetCoordinateSystemToNormalizedDisplay()
            position.SetValue(*left_down_pos)
            position2 = text_rep.GetPosition2Coordinate()
            position2.SetCoordinateSystemToNormalizedDisplay()
            position2.SetValue(*right_top_pos)
            self.SelectableOn()
            self.ResizableOff()
            text_rep.ProportionalResizeOn()
            self.On()
    text_widget = TextWidget()
    text_widget.SetRepresentation(text_rep)
    text_widget.SetInteractor(iren)
    text_widget.SetTextActor(text_actor)
    text_widget.SelectableOn()
    text_widget.ResizableOff()
    text_widget.GetRepresentation().ProportionalResizeOn()
    text_widget.AddObserver(vtk.vtkCommand.WidgetActivateEvent, callback)
    text_widget.On()
    ss = vtk.vtkSphereSource()
    mapper = vtk.vtkPolyDataMapper()
    mapper.SetInputConnection(ss.GetOutputPort())
    actor = vtk.vtkActor()
    actor.GetProperty().BackfaceCullingOff()
    return text_widget
def text ( iren , ren , callback , message = "DIPY" , left_down_pos = ( 0.8 , 0.5 ) , right_top_pos = ( 0.9 , 0.5 ) , color = ( 1. , .5 , .0 ) , opacity = 1. , border = False ) : text_actor = vtk . vtkTextActor ( ) text_actor . SetInput ( message ) text_actor . GetTextProperty ( ) . SetColor ( color ) text_actor . GetTextProperty ( ) . SetOpacity ( opacity ) text_rep = vtk . vtkTextRepresentation ( ) text_rep . SetPlaceFactor ( 1 ) text_rep . GetPositionCoordinate ( ) . SetCoordinateSystemToNormalizedDisplay ( ) text_rep . GetPositionCoordinate ( ) . SetValue ( * left_down_pos ) text_rep . GetPosition2Coordinate ( ) . SetCoordinateSystemToNormalizedDisplay ( ) text_rep . GetPosition2Coordinate ( ) . SetValue ( * right_top_pos ) if border : text_rep . SetShowBorderToOn ( ) else : text_rep . SetShowBorderToOff ( ) class TextWidget ( vtk . vtkTextWidget ) : def place ( self , renderer ) : text_rep = self . GetRepresentation ( ) position = text_rep . GetPositionCoordinate ( ) position . SetCoordinateSystemToNormalizedDisplay ( ) position . SetValue ( * left_down_pos ) position2 = text_rep . GetPosition2Coordinate ( ) position2 . SetCoordinateSystemToNormalizedDisplay ( ) position2 . SetValue ( * right_top_pos ) self . SelectableOn ( ) self . ResizableOff ( ) text_rep . ProportionalResizeOn ( ) self . On ( ) text_widget = TextWidget ( ) text_widget . SetRepresentation ( text_rep ) text_widget . SetInteractor ( iren ) text_widget . SetTextActor ( text_actor ) text_widget . SelectableOn ( ) text_widget . ResizableOff ( ) text_widget . GetRepresentation ( ) . ProportionalResizeOn ( ) text_widget . AddObserver ( vtk . vtkCommand . WidgetActivateEvent , callback ) text_widget . On ( ) ss = vtk . vtkSphereSource ( ) mapper = vtk . vtkPolyDataMapper ( ) mapper . SetInputConnection ( ss . GetOutputPort ( ) ) actor = vtk . vtkActor ( ) actor . GetProperty ( ) . BackfaceCullingOff ( ) return text_widget
2D text that can be clicked and process events
Parameters
2D text that can be clicked and process events Parameters
""" 2D text that can be clicked and process events

    Parameters
    ----------
    iren : vtkRenderWindowInteractor
        Used to process events and handle them to the button. Can also be given
        by the attribute ``ShowManager.iren``.
    ren :  vtkRenderer or Renderer
        Used to update the slider's position when the window changes. Can also
        be given by the ``ShowManager.ren`` attribute.
    callback : function
        Function that has at least ``obj`` and ``event`` as parameters. It will
        be called when the button is pressed.
    message : str
        Message to be shown in the text widget
    left_down_pos : tuple
        Normalized coordinates for left down corner of text. Default is
        (0.8, 0.5).
    right_top_pos : tuple
        Normalized coordinates for left down corner of text. Default is
        (0.9, 0.5).
    color : tuple
        Foreground RGB color of text. Default is (1., .5, .0).
    opacity : float
        Takes values from 0 to 1. Default is 1.
    border : bool
        Show text border. Default is False.

    Returns
    -------
    text : TextWidget
        This object inherits from ``vtkTextWidget`` has an additional method
        called ``place`` which allows to update the position of the text if
        necessary.
    """ # Create the TextActor # Create the text representation. Used for positioning the text_actor # This is a hack for avoiding not plotting the text widget when # backface culling in On on a different actor
iren
ren
callback
message
left_down_pos
right_top_pos
color
opacity
border