widget

Widgets are different than actors in that they can interact with events.

To do so they need as input a vtkRenderWindowInteractor also known as iren.

button(iren, ren, callback, fname[, …]) A textured two state button widget
button_display_coordinates(renderer, …)
slider(iren, ren, callback[, min_value, …]) A 2D slider widget
text(iren, ren, callback[, message, …]) 2D text that can be clicked and process events

button

fury.widget.button(iren, ren, callback, fname, right_normalized_pos=(0.98, 0.9), size=(50, 50))[source]

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.

button_display_coordinates

fury.widget.button_display_coordinates(renderer, normalized_display_position, size)[source]

slider

fury.widget.slider(iren, ren, callback, min_value=0, max_value=255, value=125, label='Slider', right_normalized_pos=(0.9, 0.5), size=(50, 0), label_format='%0.0lf', color=(0.5, 0.5, 0.5), selected_color=(0.9, 0.2, 0.1))[source]

A 2D slider widget

Parameters:
iren : vtkRenderWindowInteractor

Used to process events and handle them to the slider. 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 slider’s bar has changed.

min_value : float

Minimum value of slider.

max_value : float

Maximum value of slider.

value :

Default value of slider.

label : str

Slider’s caption.

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.

label_format: str

Formating in which the slider’s value will appear for example “%0.2lf” allows for 2 decimal values.

Returns:
slider : SliderObject

This object inherits from vtkSliderWidget and has additional method called place which allows to update the position of the slider when for example the window is resized.

text

fury.widget.text(iren, ren, callback, message='FURY', left_down_pos=(0.8, 0.5), right_top_pos=(0.9, 0.5), color=(1.0, 0.5, 0.0), opacity=1.0, border=False)[source]

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

Coordinates for left down corner of text. If float are provided, the normalized coordinate system is used, otherwise the coordinates represent pixel positions. Default is (0.8, 0.5).

right_top_pos : tuple

Coordinates for right top corner of text. If float are provided, the normalized coordinate system is used, otherwise the coordinates represent pixel positions. 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.