dipy/viz/widget.py
def button(iren, ren, callback, fname, right_normalized_pos=(.98, .9),
           size=(50, 50)):
    """ A textured two state button widget

    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.
    fname : str
        PNG file path of the icon used for the button.
    right_normalized_pos : tuple
        2d tuple holding the normalized right (X, Y) position of the slider.
    size: tuple
        2d tuple holding the size of the slider in pixels.

    Returns
    -------
    button : ButtonWidget
        This object inherits from vtkButtonWidget and has an additional  method
        called ``place`` which allows to update the position of the slider
        if necessary. For example when the renderer size changes.

    Notes
    ------
    The button and slider widgets have similar positioning system. This enables
    the developers to create a HUD-like collections of buttons and sliders on
    the right side of the window that always stays in place when the dimensions
    of the window change.
    """

    image1 = vtk.vtkPNGReader()
    image1.SetFileName(fname)
    image1.Update()

    button_rep = vtk.vtkTexturedButtonRepresentation2D()
    button_rep.SetNumberOfStates(2)
    button_rep.SetButtonTexture(0, image1.GetOutput())
    button_rep.SetButtonTexture(1, image1.GetOutput())

    class ButtonWidget(vtk.vtkButtonWidget):

        def place(self, renderer):

            bds = button_display_coordinates(renderer, right_normalized_pos,
                                             size)
            self.GetRepresentation().SetPlaceFactor(1)
            self.GetRepresentation().PlaceWidget(bds)
            self.On()

    button = ButtonWidget()
    button.SetInteractor(iren)
    button.SetRepresentation(button_rep)
    button.AddObserver(vtk.vtkCommand.StateChangedEvent, callback)
    button.place(ren)

    return button
 A textured two state button widget

    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.
    fname : str
        PNG file path of the icon used for the button.
    right_normalized_pos : tuple
        2d tuple holding the normalized right (X, Y) position of the slider.
    size: tuple
        2d tuple holding the size of the slider in pixels.

    Returns
    -------
    button : ButtonWidget
        This object inherits from vtkButtonWidget and has an additional  method
        called ``place`` which allows to update the position of the slider
        if necessary. For example when the renderer size changes.

    Notes
    ------
    The button and slider widgets have similar positioning system. This enables
    the developers to create a HUD-like collections of buttons and sliders on
    the right side of the window that always stays in place when the dimensions
    of the window change.
    
A textured two state button widget
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

button : ButtonWidget
This object inherits from vtkButtonWidget and has an additional  method
called ``place`` which allows to update the position of the slider
if necessary. For example when the renderer size changes.

Notes

The button and slider widgets have similar positioning system. This enables
the developers to create a HUD-like collections of buttons and sliders on
the right side of the window that always stays in place when the dimensions
of the window change.
A textured two state button widget 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 button : ButtonWidget This object inherits from vtkButtonWidget and has an additional method called ` ` place ` ` which allows to update the position of the slider if necessary . For example when the renderer size changes . Notes The button and slider widgets have similar positioning system . This enables the developers to create a HUD - like collections of buttons and sliders on the right side of the window that always stays in place when the dimensions of the window change .
def button(iren, ren, callback, fname, right_normalized_pos=(.98, .9),
           size=(50, 50)):
    image1 = vtk.vtkPNGReader()
    image1.SetFileName(fname)
    image1.Update()
    button_rep = vtk.vtkTexturedButtonRepresentation2D()
    button_rep.SetNumberOfStates(2)
    button_rep.SetButtonTexture(0, image1.GetOutput())
    button_rep.SetButtonTexture(1, image1.GetOutput())
    class ButtonWidget(vtk.vtkButtonWidget):
        def place(self, renderer):
            bds = button_display_coordinates(renderer, right_normalized_pos,
                                             size)
            self.GetRepresentation().SetPlaceFactor(1)
            self.GetRepresentation().PlaceWidget(bds)
            self.On()
    button = ButtonWidget()
    button.SetInteractor(iren)
    button.SetRepresentation(button_rep)
    button.AddObserver(vtk.vtkCommand.StateChangedEvent, callback)
    button.place(ren)
    return button
def button ( iren , ren , callback , fname , right_normalized_pos = ( .98 , .9 ) , size = ( 50 , 50 ) ) : image1 = vtk . vtkPNGReader ( ) image1 . SetFileName ( fname ) image1 . Update ( ) button_rep = vtk . vtkTexturedButtonRepresentation2D ( ) button_rep . SetNumberOfStates ( 2 ) button_rep . SetButtonTexture ( 0 , image1 . GetOutput ( ) ) button_rep . SetButtonTexture ( 1 , image1 . GetOutput ( ) ) class ButtonWidget ( vtk . vtkButtonWidget ) : def place ( self , renderer ) : bds = button_display_coordinates ( renderer , right_normalized_pos , size ) self . GetRepresentation ( ) . SetPlaceFactor ( 1 ) self . GetRepresentation ( ) . PlaceWidget ( bds ) self . On ( ) button = ButtonWidget ( ) button . SetInteractor ( iren ) button . SetRepresentation ( button_rep ) button . AddObserver ( vtk . vtkCommand . StateChangedEvent , callback ) button . place ( ren ) return button
A textured two state button widget
Parameters
A textured two state button widget Parameters
""" A textured two state button widget

    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.
    fname : str
        PNG file path of the icon used for the button.
    right_normalized_pos : tuple
        2d tuple holding the normalized right (X, Y) position of the slider.
    size: tuple
        2d tuple holding the size of the slider in pixels.

    Returns
    -------
    button : ButtonWidget
        This object inherits from vtkButtonWidget and has an additional  method
        called ``place`` which allows to update the position of the slider
        if necessary. For example when the renderer size changes.

    Notes
    ------
    The button and slider widgets have similar positioning system. This enables
    the developers to create a HUD-like collections of buttons and sliders on
    the right side of the window that always stays in place when the dimensions
    of the window change.
    """
iren
ren
callback
fname
right_normalized_pos
size