Welcome to MenpoWidgets - the package for fancy visualisation of Menpo objects based on Jupyter.
MenpoWidgets can be separated into a 3-level hierarchy:
menpowidgets.base
, menpowidgets.menpofit.base
: These are the end user widget functions and the only ones that are exposed at the highest level of menpowidgets
. Please refer to Menpo Widgets.ipynb and MenpoFit Widgets.ipynb in the Main Widgets folder for a full description.menpowidgets.options
, menpowidgets.menpofit.options
: These are classes that implement widgets for selecting various options, such as rendering options, landmark options, channels options etc. They can be seen as the main components of all top level widgets. Please refer to Options Widgets.ipynb in the Custom Widgets folder for a full description.menpowidgets.tools
: These are classes that implement lower level widget functionalities, such as colour selection, zoom options, axes options, etc. They are the main ingredients of the main widget components of the previous level. Please refer to Widgets Tools.ipynb in the Custom Widgets folder for a full description.All our widgets are subclasses of menpowidgets.abstract.MenpoWidget
which is an ipywidgets.FlexBox
. Thus all our widgets have the following functionalities:
trait
named selected_values
is added, which is monitoring any change that takes place in the widget and which should trigger a rendering function. The type of the trait can vary among widgets (e.g. Int
, Dict
, etc.) and its role is to store the selected values of the various widget components. render_function
argument.add_render_function()
: It attaches a new rendering function as callback to the selected_values
trait
.remove_render_function()
: It removes the current rendering function callback.replace_render_function()
: It replaces the current rendering function callback with a new one.call_render_function()
: It triggers the attached rendering function.Note that
render_function()
must have the following signature:input_dict = {'type': 'change', 'name': type_value, 'owner': '', 'old': old_value, 'new': new_value} render_function(input_dict)
Additionally, all widgets have the following functions:
set_widget_state()
: It updates the widget state with a new set of options (i.e., selected_values
). It has an allow_callback
argument that defines whether the render function is allowed to be triggered if required.style()
: It takes a set of options that change the style of the widget, such as font-related options, border-related options, etc.predefined_style()
: It sets some predefined styles (themes) on the widget. Possible options are 'minimal'
, 'success'
, 'info'
, 'warning'
and 'danger'
.