API Reference for Enthought Tool Suite 2.7.1
Provides a framework that assembles Traits UI Views at run time, when the view is requested, rather than at the time a class is written.
This capability is particularly useful when the object being 'viewed' with a Traits UI is part of a plug-in application -- such as Envisage. In general, this capability allows:
Either the original object writer, or a contributor, can use this framework to declare one or more dynamic views that are composed of sub-elements that only need to exist at the time the view is requested.
Users of this framework create a dynamic view by registering a DynamicView declaration. That declaration includes a name that forms the basis for the metadata attributes that are used to identify and order the desired view sub-elements into the view's composition. In addition, the declaration includes any data to be passed into the constructor of the dynamic view and the id that should be used to persist the user's customization of the view.
Additionally, this framework allows sub-elements themselves to also be dynamically composed of further sub-elements.
For example, a dynamic view could be composed of two sub-elements:
Programmers include dynamic sub-elements within their dynamic views by contributing a DynamicViewSubElement into that view. When the framework comes across this contribution while building the view, it replaces that DynamicViewSubElement with a fully initialized Traits ViewSubElement composed in a manner similar to how the elements of the View itself were composed.
Each contribution to a dynamic view or sub-element must be an instance of a Traits ViewSubElement and must have associated metadata like the following for each dynamic view or sub-element it will display in:
In addition, dynamic view contributions can also provide a 'handler', which behaves like a normal Traits Handler. That is, it can contain methods that are called when model values change and can access the Traits UIInfo object representing the actual UI instances. To provide a handler, append the following metadata to your view sub-element:
Setup a logger for this module.
logger = logging.getLogger(__name__)
| Local name | Refers to |
|---|---|
| Any | enthought.traits.traits.Any |
| Bool | enthought.traits.traits.Bool |
| DelegatingHandler | enthought.traits.ui.delegating_handler.DelegatingHandler |
| Dict | enthought.traits.traits.Dict |
| HasTraits | enthought.traits.has_traits.HasTraits |
| Instance | enthought.traits.traits.Instance |
| logging | logging |
| Str | enthought.traits.traits.Str |
| View | enthought.traits.ui.view.View |
| ViewElement | enthought.traits.ui.view_element.ViewElement |
| ViewSubElement | enthought.traits.ui.view_element.ViewSubElement |
Copyright © 2002-2008 Enthought, Inc.