ButtonManager#

class ansys.tools.visualization_interface.backends.plotly.widgets.button_manager.ButtonManager(fig: plotly.graph_objects.Figure)#

Class to manage buttons in a Plotly figure.

This class allows adding buttons to a Plotly figure for various functionalities such as toggling visibility of traces, resetting the view, and custom actions.

Parameters:
figgo.Figure

The Plotly figure to which buttons will be added.

Overview#

add_button

Add a button to the Plotly figure.

show_hide_bbox_dict

Generate dictionary for showing/hiding coordinate system elements.

update_layout

Update the figure layout with all controls as buttons in a single row.

args_xy_view_button

Get camera configuration for XY plane view (top-down view).

args_xz_view_button

Get camera configuration for XZ plane view (front view).

args_yz_view_button

Get camera configuration for YZ plane view (side view).

args_iso_view_button

Get camera configuration for isometric view (3D perspective).

add_measurement_toggle_button

Get configuration for measurement toggle button.

args_projection_toggle_button

Get configuration for projection toggle button.

args_theme_toggle_button

Get configuration for theme toggle button.

Import detail#

from ansys.tools.visualization_interface.backends.plotly.widgets.button_manager import ButtonManager

Method detail#

ButtonManager.add_button(label: str, x: float, y: float, xanchor: str = 'left', yanchor: str = 'bottom', method: str = 'restyle', args: List[Any] = None, args2: List[Any] = None) None#

Add a button to the Plotly figure.

Parameters:
labelstr

The text to display on the button.

xfloat

X position of the button (0-1).

yfloat

Y position of the button (0-1).

xanchorstr, optional

X anchor point for the button, by default “left”.

yanchorstr, optional

Y anchor point for the button, by default “bottom”.

methodstr, optional

The method to call when the button is clicked. Options include: ‘restyle’, ‘relayout’, ‘update’, ‘animate’, by default ‘restyle’.

argsList[Any], optional

Arguments to pass to the method when the button is clicked, by default None.

args2List[Any], optional

Secondary arguments for toggle functionality, by default None.

ButtonManager.show_hide_bbox_dict(toggle: bool = True)#

Generate dictionary for showing/hiding coordinate system elements.

Parameters:
togglebool, optional

Whether to show (True) or hide (False) the coordinate system, by default True.

Returns:
dict

Dictionary with coordinate system visibility settings.

ButtonManager.update_layout() None#

Update the figure layout with all controls as buttons in a single row.

This method builds buttons using the configuration methods and any additional buttons that were added via add_button().

ButtonManager.args_xy_view_button(label: str = 'XY View', x: float = 0.02, y: float = 1.02) dict#

Get camera configuration for XY plane view (top-down view).

Parameters:
labelstr, optional

The text to display on the button, by default “XY View”.

xfloat, optional

X position of the button (0-1), by default 0.02.

yfloat, optional

Y position of the button (0-1), by default 1.02.

Returns:
dict

Camera configuration for XY plane view.

ButtonManager.args_xz_view_button(label: str = 'XZ View', x: float = 0.02, y: float = 1.02) dict#

Get camera configuration for XZ plane view (front view).

Parameters:
labelstr, optional

The text to display on the button, by default “XZ View”.

xfloat, optional

X position of the button (0-1), by default 0.02.

yfloat, optional

Y position of the button (0-1), by default 1.02.

Returns:
dict

Camera configuration for XZ plane view.

ButtonManager.args_yz_view_button(label: str = 'YZ View', x: float = 0.02, y: float = 1.02) dict#

Get camera configuration for YZ plane view (side view).

Parameters:
labelstr, optional

The text to display on the button, by default “YZ View”.

xfloat, optional

X position of the button (0-1), by default 0.02.

yfloat, optional

Y position of the button (0-1), by default 1.02.

Returns:
dict

Camera configuration for YZ plane view.

ButtonManager.args_iso_view_button(label: str = 'ISO View', x: float = 0.02, y: float = 1.02) dict#

Get camera configuration for isometric view (3D perspective).

Parameters:
labelstr, optional

The text to display on the button, by default “ISO View”.

xfloat, optional

X position of the button (0-1), by default 0.02.

yfloat, optional

Y position of the button (0-1), by default 1.02.

Returns:
dict

Camera configuration for isometric view.

ButtonManager.add_measurement_toggle_button(label: str = 'Toggle Measurement', x: float = 0.02, y: float = 0.87) Tuple[dict, dict]#

Get configuration for measurement toggle button.

Parameters:
labelstr, optional

The text to display on the button, by default “Toggle Measurement”.

xfloat, optional

X position of the button (0-1), by default 0.02.

yfloat, optional

Y position of the button (0-1), by default 0.87.

Returns:
Tuple[dict, dict]

Tuple containing (enable_measurement_config, disable_measurement_config).

ButtonManager.args_projection_toggle_button() Tuple[dict, dict]#

Get configuration for projection toggle button.

Parameters:
labelstr, optional

The text to display on the button, by default “Toggle Projection”.

xfloat, optional

X position of the button (0-1), by default 0.14.

yfloat, optional

Y position of the button (0-1), by default 1.02.

Returns:
Tuple[dict, dict]

Tuple containing (perspective_projection_config, orthographic_projection_config).

ButtonManager.args_theme_toggle_button(label: str = 'Toggle Theme', x: float = 0.32, y: float = 1.02) Tuple[dict, dict]#

Get configuration for theme toggle button.

Parameters:
labelstr, optional

The text to display on the button, by default “Toggle Theme”.

xfloat, optional

X position of the button (0-1), by default 0.22.

yfloat, optional

Y position of the button (0-1), by default 1.02.

Returns:
Tuple[dict, dict]

Tuple containing (light_theme_config, dark_theme_config).