traitsui.ui module

Defines the UI class used to represent an active traits-based user interface.

class traitsui.ui.Dispatcher(method, info, object, method_name)[source]

Bases: object

dispatch()[source]

Dispatches the method.

remove()[source]

Removes the dispatcher.

class traitsui.ui.UI[source]

Bases: HasPrivateTraits

Information about the user interface for a View.

add_checked(checked_when, editor)[source]

Adds a conditionally enabled (menu) Editor object to the list of monitored ‘checked_when’ objects.

add_defined(method)[source]

Adds a Handler method to the list of methods to be called once the user interface has been constructed.

add_enabled(enabled_when, editor)[source]

Adds a conditionally enabled Editor object to the list of monitored ‘enabled_when’ objects.

add_visible(visible_when, editor)[source]

Adds a conditionally enabled Editor object to the list of monitored ‘visible_when’ objects.

context = Dict(Str, Any)

Context objects that the UI is editing

control = Any()

Panel or dialog associated with the user interface

destroyed = Bool(False)

Set to True when the UI has finished being destroyed.

disposable_traits = ['view_elements', 'info', 'handler', 'context', 'view', 'history', 'key_bindings', 'icon', 'rebuild']

List of additional traits that are discarded when a user interface is disposed.

dispose(result=None, abort=False)[source]

Disposes of the contents of a user interface.

do_undoable(action, *args, **kw)[source]

Performs an action that can be undone.

errors = Int()

The number of currently pending editor error conditions

eval_when(when, result=True)[source]

Evaluates an expression in the UI’s context and returns the result.

evaluate(function, *args, **kw_args)[source]

Evaluates a specified function in the UI’s context.

find(include)[source]

Finds the definition of the specified Include object in the current user interface building context.

finish()[source]

Finishes disposing of a user interface.

get_editors(name)[source]

Returns a list of editors for the given trait name.

get_error_controls()[source]

Returns the list of editor error controls contained by the user interface.

get_extended_value(name)[source]

Gets the current value of a specified extended trait name.

get_prefs(prefs=None)[source]

Gets the preferences to be saved for the user interface.

get_ui_db(mode='r')[source]

Returns a reference to the Traits UI preference database.

handler = Instance(Handler)

Handler object used for event handling

history = Any()

Undo and Redo history

icon = Image

The ImageResource of the icon, if any

id = Str()

The unique ID for this UI for persistence

info = Instance(UIInfo)

UIInfo object containing context or editor objects

key_bindings = Property(depends_on=["view._key_bindings", "context"])

The KeyBindings object (if any) for this UI:

key_handler(event, skip=True)[source]

Handles key events.

modified = Bool(False)

Have any modifications been made to UI contents?

owner = Any()

Toolkit-specific object that “owns” control

parent = Instance("UI")

The parent UI (if any) of this UI

pop_level(level)[source]

Restores a previously pushed search stack level.

prepare_ui()[source]

Performs all processing that occurs after the user interface is created.

push_level()[source]

Returns the current search stack level.

rebuild = Callable()

The code used to rebuild an updated user interface

recyclable_traits = ['_context', '_revert', '_defined', '_visible', '_enabled', '_checked', '_search', '_dispatchers', '_editors', '_names', '_active_group', '_undoable', '_rebuild', '_groups_cache', '_key_bindings', '_focus_control']

List of traits that are reset when a user interface is recycled (i.e. rebuilt).

recycle()[source]

Recycles the user interface prior to rebuilding it.

reset(destroy=True)[source]

Resets the contents of a user interface.

restore_prefs()[source]

Retrieves and restores any saved user preference information associated with the UI.

result = Bool(False)

Result from a modal or wizard dialog:

route_event(event)[source]

Routes a “hooked” event to the correct handler method.

save_prefs(prefs=None)[source]

Saves any user preference information associated with the UI.

scrollable = Bool(False)

Should the created UI have scroll bars?

set_prefs(prefs)[source]

Sets the values of user preferences for the UI.

sync_view()[source]

Synchronize context object traits with view editor traits.

title = Str()

Title of the dialog, if any

traits_init()[source]

Initializes the traits object.

ui(parent, kind)[source]

Creates a user interface from the associated View template object.

updated = Event(Bool)

Event when the user interface has changed

view = Instance("traitsui.view.View")

View template used to construct the user interface

view_elements = Instance(ViewElements)

The ViewElements object from which this UI resolves Include items