ipyoverlay.container.OverlayContainer#

class ipyoverlay.container.OverlayContainer(**kwargs)#

Bases: VuetifyTemplate

A wrapper for a background set of components that can render other ipywidgets over the background.

Methods

__init__([widget])

Public constructor

add_child(obj[, left, top])

Add the passed widget as an overlay at the specified position.

add_child_at_mpl_point(obj, axis, data_x, data_y)

Add the passed widget as an overlay and connect it to a matplotlib figure at the specified data location.

add_class(className)

Adds a class to the top level element of the widget.

add_traits(**traits)

Dynamically add trait attributes to the Widget.

blur()

Blur the widget.

class_own_trait_events(name)

Get a dict of all event handlers defined on this class, not a parent.

class_own_traits(**metadata)

Get a dict of all the traitlets defined on this class, not a parent.

class_trait_names(**metadata)

Get a list of all the names of this class' traits.

class_traits(**metadata)

Get a dict of all the traits of this class.

close()

Close method.

close_all()

connect_child_to_mpl(child, axis, data_x, data_y)

Make a connection that moves around with a draggable child and a point in a matplotlib axis.

connect_child_to_pixel(child, point)

Make a connection that moves around with a draggable child and a static point.

connect_child_to_plotly(child, fig_widget, ...)

Make a connection that moves around with a draggable child and a point in a plotly figure.

fire_on_rendered()

Trigger all registered on_rendered callbacks.

fire_on_resized(width, height)

Trigger all registered on_resized callbacks.

focus()

Focus on the widget.

get_current_width_height()

Ask JS to update our current_width and current_height variables to reflect current overlay container dimensions.

get_manager_state([drop_defaults, widgets])

Returns the full state for a widget manager for embedding

get_relative_layout_position(x, y, ...[, ...])

param radius:

How far out to get a position. Leave -1 to compute based on

get_state([key, drop_defaults])

Gets the widget state, or a piece of it.

get_view_spec()

handle_comm_opened(comm, msg)

Static method, called when a widget is constructed.

handle_control_comm_opened(comm, msg)

Class method, called when the comm-open message on the "jupyter.widget.control" comm channel is received

has_trait(name)

Returns True if the object has a trait with the specified name.

hold_sync()

Hold syncing any state until the outermost context manager exits

hold_trait_notifications()

Context manager for bundling trait change notifications and cross validation.

move_child(child, x, y)

Move the specified child to the specified (left, top).

move_child_client_px(child, x, y)

Move the specified child to the specified (left, top).

notify_change(change)

Called when a property has changed.

observe(handler[, names, type])

Setup a handler to be called when a trait changes.

on_msg(callback[, remove])

(Un)Register a custom msg receive callback.

on_rendered(callback)

Register a callback to execute when the container is rendered and displayed.

on_resized(callback)

Register a callback to execute when the container's size is changed.

on_trait_change([handler, name, remove])

DEPRECATED: Setup a handler to be called when a trait changes.

on_widget_constructed(callback)

Registers a callback to be called when a widget is constructed.

open()

Open a comm to the frontend if one isn't already open.

remove_child(obj)

Remove the passed child from the container.

remove_class(className)

Removes a class from the top level element of the widget.

send(content[, buffers])

Sends a custom msg to the widget model in the front-end.

send_state([key])

Sends the widget state, or a piece of it, to the front-end, if it exists.

set_state(sync_data)

Called when a state is received from the front-end.

set_trait(name, value)

Forcibly sets trait attribute, including read-only attributes.

setup_instance(**kwargs)

This is called before self.__init__ is called.

trait_defaults(*names, **metadata)

Return a trait's default value or a dictionary of them

trait_events([name])

Get a dict of all the event handlers of this class.

trait_has_value(name)

Returns True if the specified trait has a value.

trait_metadata(traitname, key[, default])

Get metadata values for trait by key.

trait_names(**metadata)

Get a list of all the names of this class' traits.

trait_values(**metadata)

A dict of trait names and their values.

traits(**metadata)

Get a dict of all the traits of this class.

unobserve(handler[, names, type])

Remove a trait change handler.

unobserve_all([name])

Remove trait change handlers of any type for the specified name.

vue_handle_child_mouse_down(event)

Event handler for when the mouse is clicked on an overlay component.

vue_handle_mouse_down(e)

Event handler for when the mouse is clicked not on an overlay component.

vue_handle_mouse_up(e)

Event handler for when the mouse button is released.

vue_handle_rendered(e)

Event handler for when the componet is rendered in JS.

vue_handle_resize(e)

Event handler for when the container's size changes.

Attributes

child_connections_info

A list of lists containing the connection ids associated with each child widget.

children

The set of widgets rendered as overlays over the background widget.

class_component_serialization

comm

A trait which allows any value.

components

An instance of a Python dict.

container_id

A trait for unicode strings.

cross_validation_lock

A contextmanager for running a block with our cross validation lock set to True.

css

A trait for unicode strings.

current_height

Read-only traitlet used for JS to communicate actual current size to python side.

current_width

Read-only traitlet used for JS to communicate actual current size to python side.

data

A trait for unicode strings.

detail_connections

A list of connection widgets for each child.

dragging

A boolean (True, False) trait.

dragging_index

An int trait.

events

An instance of a Python list.

expandable

Whether to allow (and show button for) expanding the container to take up full notebook window.

expanded

Get/set whether currently expanded to full notebook window or not.

height

Height of the container, set to 'auto' to autoscale.

keys

The traits which are synced.

layout

An instance trait which coerces a dict to an instance.

log

A trait whose value must be an instance of a specified class.

methods

A trait for unicode strings.

model_id

Gets the model id of this widget.

tabbable

Is widget tabbable?

template

A trait type representing a Union type.

template_file

tooltip

A tooltip caption.

widget

The background widget/layout this container should wrap and render things over.

widget_types

widgets

width

Width of the container, set to 'auto' to autoscale.

add_child(obj, left=0, top=0)#

Add the passed widget as an overlay at the specified position.

Parameters:
  • obj (Widget) – The ipywidget to add, recommend wrapping in DecoratedWidgetWrapper to support additional features like click/drag etc.

  • left (int) – Position from the left in pixels to render widget at.

  • top (int) – Position from the top in pixels to render widget at.

add_child_at_mpl_point(obj, axis, data_x, data_y)#

Add the passed widget as an overlay and connect it to a matplotlib figure at the specified data location.

Parameters:
  • obj (Widget) – The ipywidget to add, recommend wrapping in DecoratedWidgetWrapper to support additional features like click/drag etc.

  • axis (Axes) – The matplotlib axis object containing the data location to connect to.

  • data_x (float) – The x-value within the axis to show the connection endpoint.

  • data_y (float) – The y-value within the axis to show the connection endpoint.

child_connections_info#

A list of lists containing the connection ids associated with each child widget.

children#

The set of widgets rendered as overlays over the background widget.

connect_child_to_mpl(child, axis, data_x, data_y)#

Make a connection that moves around with a draggable child and a point in a matplotlib axis.

Parameters:
  • child – The widget to draw a connection line from.

  • axis (Axes) – The matplotlib axis object containing the data location to connect to.

  • data_x (float) – The x-value within the axis to show the connection endpoint.

  • data_y (float) – The y-value within the axis to show the connection endpoint.

connect_child_to_pixel(child, point)#

Make a connection that moves around with a draggable child and a static point.

Parameters:

point (tuple[int, int]) –

Return type:

Connection

connect_child_to_plotly(child, fig_widget, data_x, data_y)#

Make a connection that moves around with a draggable child and a point in a plotly figure.

Parameters:
  • fig_widget (FigureWidget) –

  • data_x (float) –

  • data_y (float) –

container_id#

A trait for unicode strings.

current_height#

Read-only traitlet used for JS to communicate actual current size to python side.

current_width#

Read-only traitlet used for JS to communicate actual current size to python side.

detail_connections#

A list of connection widgets for each child.

dragging#

A boolean (True, False) trait.

dragging_index#

An int trait.

expandable#

Whether to allow (and show button for) expanding the container to take up full notebook window.

expanded#

Get/set whether currently expanded to full notebook window or not.

fire_on_rendered()#

Trigger all registered on_rendered callbacks.

fire_on_resized(width, height)#

Trigger all registered on_resized callbacks.

Parameters:
  • width (int) –

  • height (int) –

get_current_width_height()#

Ask JS to update our current_width and current_height variables to reflect current overlay container dimensions.

Return type:

tuple[int, int]

get_relative_layout_position(x, y, relative_points_x, relative_points_y, radius=-1, source='mpl', force=False)#
Parameters:
  • radius (float | int) – How far out to get a position. Leave -1 to compute based on relative points.

  • source (str) – How to consider data

  • force (bool) – Whether to move other widgets around to make fit better or not.

  • relative_points_x (ndarray) –

  • relative_points_y (ndarray) –

Return type:

tuple[float, float]

height#

Height of the container, set to ‘auto’ to autoscale.

move_child(child, x, y)#

Move the specified child to the specified (left, top).

The pixel values for left/top should be local to the container.

Parameters:
  • x (int) –

  • y (int) –

move_child_client_px(child, x, y)#

Move the specified child to the specified (left, top).

The pixel values for left/top are clientX/clientY values wrt to the page, (e.g. what you would get from mouse events), not the left/top within the container.

Parameters:
  • x (int) –

  • y (int) –

on_rendered(callback)#

Register a callback to execute when the container is rendered and displayed.

Nothing is passed to the callback.

Parameters:

callback (Callable) –

on_resized(callback)#

Register a callback to execute when the container’s size is changed.

The callback will be passed the new width and height as integers.

Parameters:

callback (Callable[[int, int], None]) –

remove_child(obj)#

Remove the passed child from the container.

vue_handle_child_mouse_down(event)#

Event handler for when the mouse is clicked on an overlay component.

vue_handle_mouse_down(e)#

Event handler for when the mouse is clicked not on an overlay component.

vue_handle_mouse_up(e)#

Event handler for when the mouse button is released.

Connection endpoint updates get handled here.

vue_handle_rendered(e)#

Event handler for when the componet is rendered in JS. This gets propagated through on_resized handlers.

vue_handle_resize(e)#

Event handler for when the container’s size changes. This gets propagated through on_resized handlers.

widget#

The background widget/layout this container should wrap and render things over.

width#

Width of the container, set to ‘auto’ to autoscale.