spectacoular.factory.get_widgets¶
- spectacoular.factory.get_widgets(self, trait_widget_mapper={}, trait_widget_args={})¶
This function creates a View (a bunch of instanciated widgets without a layout) defined by the
trait_widget_mapper
mapping attribute of the given object (or specified viaget_widgets()
method arguments).This function is implemented in all SpectAcoular classes and is added to Acoular’s classes in bokehview.py. It builds Bokeh widgets from corresponding class trait attributes by utilizing the
TraitWidgetMapper
derived classes. The desired mapping is defined by thetrait_widget_mapper
dictionary.This function implements multiple cases of View construction:
(Case 1 - Default View) get_widgets() is called by a BaseSpectacoular derived instance without specifying trait_widget_mapper and trait_widget_args as function arguments. In this case, the mapping defined by the object instance attributes (self.trait_widget_mapper,self.`trait_widget_args`) will be used to construct the View.
(Case 2 - Custom View (a)) get_widgets() is called by a BaseSpectacoular derived instance and the desired mapping is given by the
get_widgets()
function arguments (trait_widget_mapper and trait_widget_args). In this case, the mapping defined by the function arguments will be used to create the View. The instance attributes (self.trait_widget_mapper,self.`trait_widget_args`) will be superseded.(Case 3 - No Predefined View)
get_widgets()
is called and a HasTraits derived instance is given as the first argument to the function. The instance object has no trait_widget_mapper and trait_widget_args attributes. In this case, a default mapping is created from all editable traits to create the view.(Case 4 - Custom View (b))
get_widgets()
is called and a HasTraits derived instance is given as the first argument to the function. The instance object has no trait_widget_mapper and trait_widget_args attributes, but a mapping is defined by the second (and third) function argument. In this case, the mapping defined by the function arguments will be used to create the View.
- Parameters:
- trait_widget_mapperdict, optional
contains the desired mapping of a variable name (dict key) to a Bokeh widget type (dict value), by default {}
- trait_widget_argsdict, optional
- contains the desired widget kwargs (dict values) for each variable name (dict key),
by default {}
- Returns:
- dict
A dictionary containing the variable names as the key and the Bokeh widget instance as value.