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)

Bases: object

dispatch()

Dispatches the method.

remove()

Removes the dispatcher.

class traitsui.ui.UI

Bases: traits.has_traits.HasPrivateTraits

Information about the user interface for a View.

add_checked(checked_when, editor)

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

add_defined(method)

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

add_enabled(enabled_when, editor)

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

add_visible(visible_when, editor)

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)

Disposes of the contents of a user interface.

do_undoable(action, *args, **kw)

Performs an action that can be undone.

errors = Int()

The number of currently pending editor error conditions

eval_when(when, result=True)

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

evaluate(function, *args, **kw_args)

Evaluates a specified function in the UI’s context.

find(include)

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

finish()

Finishes disposing of a user interface.

get_editors(name)

Returns a list of editors for the given trait name.

get_error_controls()

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

get_extended_value(name)

Gets the current value of a specified extended trait name.

get_prefs(prefs=None)

Gets the preferences to be saved for the user interface.

get_ui_db(mode='r')

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)

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)

Restores a previously pushed search stack level.

prepare_ui()

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

push_level()

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()

Recycles the user interface prior to rebuilding it.

reset(destroy=True)

Resets the contents of a user interface.

restore_prefs()

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)

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

save_prefs(prefs=None)

Saves any user preference information associated with the UI.

scrollable = Bool(False)

Should the created UI have scroll bars?

set_prefs(prefs)

Sets the values of user preferences for the UI.

sync_view()

Synchronize context object traits with view editor traits.

title = Str()

Title of the dialog, if any

traits_init()

Initializes the traits object.

ui(parent, kind)

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