FormElement

class glue.viewers.custom.qt.custom_viewer.FormElement(params)[source]

Bases: object

Base class for user-defined settings in a custom widget.

Each form element has a value() and a widget. Subclasses must override _build_ui, value, and recognizes. They may override register_to_hub and add_data.

Attributes Summary

state

Methods Summary

add_callback(cb) Register a new callback function to be invoked
add_data(data) Add data to the element
auto(params) Construct the appropriate FormElement subclass, given a shorthand object.
changed()
dereference(elements[, layer]) Given a dict of elements, extract their current settings
recognizes(params) Returns whether or not a shorthand “params” object
register_to_hub(hub) Register the element to the hub
value([layer, view]) Extract the value of this element

Attributes Documentation

state[source]

Methods Documentation

add_callback(cb)[source]

Register a new callback function to be invoked when the form state changes

add_data(data)[source]

Add data to the element

static auto(params)[source]

Construct the appropriate FormElement subclass, given a shorthand object. For examle, FormElement.auto((0., 1.)) returns a NumberElement

changed()[source]
static dereference(elements, layer=None)[source]

Given a dict of elements, extract their current settings into a dict

Parameters:
  • elements – dict mapping labels -> FormElements
  • layer – Subset or Data object as reference
Reteurns:

dict mapping labels -> setting value

classmethod recognizes(params)[source]

Returns whether or not a shorthand “params” object can be passed to __init__ to construct an element

register_to_hub(hub)[source]

Register the element to the hub

value(layer=None, view=None)[source]

Extract the value of this element

Parameters:layer – The Data or Subset object to use, if extracting numerical data