Defines the View class used to represent the structural content of a Traits-based user interface.
A Traits-based user interface for one or more objects.
The attributes of the View object determine the contents and layout of an attribute-editing window. A View object contains a set of Group, Item, and Include objects. A View object can be an attribute of an object derived from HasTraits, or it can be a standalone object.
The ActionManagerBuilder to use with menu and toolbar schemas. The controller will usually be overridden.
List of button actions to add to the view. The traitsui.menu module defines standard buttons, such as OKButton, and standard sets of buttons, such as ModalButtons, which can be used to define a value for this attribute. This value can also be a list of button name strings, such as
['OK', 'Cancel', 'Help']. If set to the empty list, the view contains a default set of buttons (equivalent to LiveButtons: Undo/Redo, Revert, OK, Cancel, Help). To suppress buttons in the view, use the NoButtons variable, defined in traitsui.menu.
What result should be returned if the user clicks the window or dialog close button or icon?
The top-level Group object for the view:
The default button to activate when Enter is pressed. If not specified, pressing Enter will not activate any button.
The default docking style to use for sub-groups of the view. The following values are possible:
‘fixed’: No rearrangement of sub-groups is allowed.
‘horizontal’: Moveable elements have a visual “handle” to the left by which the element can be dragged.
‘vertical’: Moveable elements have a visual “handle” above them by which the element can be dragged.
‘tabbed’: Moveable elements appear as tabbed pages, which can be arranged within the window or “stacked” so that only one appears at at a time.
Class of dropped objects that can be added:
The category of exported elements:
The Handler object that provides GUI logic for handling events in the window. Set this attribute only if you are using a custom Handler. If not set, the default Traits UI Handler is used.
Requested height for the view window, as an (integer) number of pixels, or as a (floating point) fraction of the screen height.
External help context identifier, which can be used by a custom help handler. This attribute is ignored by the default help handler.
The name of the icon to display in the dialog window title bar:
A unique identifier for the view:
The image to display on notebook tabs:
The valid categories of imported elements:
The set of global key bindings for the view. Each time a key is pressed while the view has keyboard focus, the key is checked to see if it is one of the keys recognized by the KeyBindings object. If it is, the matching KeyBinding’s method name is checked to see if it is defined on any of the object’s in the view’s context. If it is, the method is invoked. If the result of the method is False, then the search continues with the next object in the context. If any invoked method returns a non-False value, processing stops and the key is marked as having been handled. If all invoked methods return False, or no matching KeyBinding object is found, the key is processed normally. If the view has a non-empty id trait, the contents of the KeyBindings object will be saved as part of the view’s persistent data:
The kind of user interface to create:
The menu bar for the view. Usually requires a custom handler. This may be either a MenuBarManager or a MenuBarSchema
The factory function for converting a model into a model/view object:
The default object being edited:
Called when modal changes are applied or reverted:
Replaces any items that have an ID with an Include object with the same ID, and puts the object with the ID into the specified ViewElements object.
Can the user resize the window?
Can the user scroll the view? If set to True, window-level scroll bars appear whenever the window is too small to show all of its contents at one time. If set to False, the window does not scroll, but individual widgets might still contain scroll bars.
Sets the content of a view.
Status bar items to add to the view’s status bar. The value can be:
None: No status bar for the view (the default).
string: Same as [ StatusItem( name = string ) ].
StatusItem: Same as [ StatusItem ].
[ [StatusItem|string], … ]: Create a status bar with one field for each StatusItem in the list (or tuple). The status bar fields are defined from left to right in the order specified. A string value is converted to: StatusItem( name = string ):
The default editor style of elements in the view:
Title for the view, displayed in the title bar when the view appears as a secondary window (i.e., dialog or wizard). If not specified, “Edit properties” is used as the title.
The toolbar for the view. Usually requires a custom handler. This may be either a ToolBarManager or a ToolBarSchema
ui(context, parent=None, kind=None, view_elements=None, handler=None, id='', scrollable=None, args=None)¶
Creates a UI object, which generates the actual GUI window or panel from a set of view elements.
context (object or dictionary) – A single object or a dictionary of string/object pairs, whose trait attributes are to be edited. If not specified, the current object is used.
parent (window component) – The window parent of the View object’s window
kind (string) – The kind of window to create. See the AKind trait for details. If kind is unspecified or None, the kind attribute of the View object is used.
view_elements (ViewElements object) – The set of Group, Item, and Include objects contained in the view. Do not use this parameter when calling this method directly.
handler (Handler object) – A handler object used for event handling in the dialog box. If None, the default handler for Traits UI is used.
id (string) – A unique ID for persisting preferences about this user interface, such as size and position. If not specified, no user preferences are saved.
scrollable (Boolean) – Indicates whether the dialog box should be scrollable. When set to True, scroll bars appear on the dialog box if it is not large enough to display all of the items in the view at one time.
Event when the view has been updated:
Requested width for the view window, as an (integer) number of pixels, or as a (floating point) fraction of the screen width.
Requested x-coordinate (horizontal position) for the view window. This attribute can be specified in the following ways:
A positive integer: indicates the number of pixels from the left edge of the screen to the left edge of the window.
A negative integer: indicates the number of pixels from the right edge of the screen to the right edge of the window.
A floating point value between 0 and 1: indicates the fraction of the total screen width between the left edge of the screen and the left edge of the window.
A floating point value between -1 and 0: indicates the fraction of the total screen width between the right edge of the screen and the right edge of the window.
Requested y-coordinate (vertical position) for the view window. This attribute behaves exactly like the x attribute, except that its value indicates the position of the top or bottom of the view window relative to the top or bottom of the screen.