ipyoverlay.widgets.ContextMenu#
- class ipyoverlay.widgets.ContextMenu(**kwargs)#
Bases:
VuetifyTemplateA menu of clickable options that can trigger provided event handlers. This should be used in tandem with a ContextMenuArea.
- Parameters:
options (dict[str, str | tuple[str, Callable]]) – The options to display in the menu. The keys represent a backend string to track, which the event handlers can check for, and the values are either strings (the html to display for the option, or a tuple of the html and an event handler to call specifically for that option.
Methods
__init__([options])Public constructor
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
dictof all the traits of this class.close()Close method.
close_all()fire_on_option_clicked(option_key, event_data)Trigger all registered on_option_clicked callbacks.
focus()Focus on the widget.
get_manager_state([drop_defaults, widgets])Returns the full state for a widget manager for embedding
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.
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_option_clicked(callback[, option])If option is None, call this callback when any option is clicked.
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.
When the container detects a click on a widget, it calls this to determine if it should handle it (
True, container will then handle dragging logic) or if this widget will handle it (False).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_options(options)NOTE: does not currently remove previous event handlers.
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
dictof 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
dictof trait names and their values.traits(**metadata)Get a
dictof 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.
Event handler for when an option in the vue-component is clicked.
Attributes
A trait for unicode strings.
class_component_serializationcommA trait which allows any value.
componentsAn instance of a Python dict.
cross_validation_lockA contextmanager for running a block with our cross validation lock set to True.
cssA trait for unicode strings.
dataA trait for unicode strings.
eventsAn instance of a Python list.
A trait for unicode strings.
keysThe traits which are synced.
layoutAn instance trait which coerces a dict to an instance.
logA trait whose value must be an instance of a specified class.
A trait for unicode strings.
methodsA trait for unicode strings.
model_idGets the model id of this widget.
An instance of a Python dict.
tabbableIs widget tabbable?
templateA trait type representing a Union type.
template_filetooltipA tooltip caption.
A boolean (True, False) trait.
widget_typeswidgetsAn int trait.
- background_color#
A trait for unicode strings.
- fire_on_option_clicked(option_key, event_data)#
Trigger all registered on_option_clicked callbacks.
- hover_color#
A trait for unicode strings.
- menu_id#
A trait for unicode strings.
- on_option_clicked(callback, option=None)#
If option is None, call this callback when any option is clicked.
The callback will be passed the option key from the options dictionary, and an event_data dictionary containing mouse coordinates of the original right click.
- Parameters:
option (str) –
- options#
An instance of a Python dict.
One or more traits can be passed to the constructor to validate the keys and/or values of the dict. If you need more detailed validation, you may use a custom validator method.
Changed in version 5.0: Added key_trait for validating dict keys.
Changed in version 5.0: Deprecated ambiguous
trait,traitsargs in favor ofvalue_trait,per_key_traits.
- overlay_container_should_handle_click(e)#
When the container detects a click on a widget, it calls this to determine if it should handle it (
True, container will then handle dragging logic) or if this widget will handle it (False).- Return type:
bool
- set_options(options)#
NOTE: does not currently remove previous event handlers.
- Parameters:
options (dict[str, str | tuple[str, Callable]]) –
- visible#
A boolean (True, False) trait.
- vue_handle_option_clicked(data)#
Event handler for when an option in the vue-component is clicked.
- width#
An int trait.