traitsui.toolkit module

Defines the stub functions used for creating concrete implementations of the standard EditorFactory subclasses supplied with the Traits package.

Most of the logic for determining which backend toolkit to use can now be found in pyface.base_toolkit.

class traitsui.toolkit.Toolkit(package, toolkit, *packages, **traits)

Bases: pyface.base_toolkit.Toolkit

Abstract base class for GUI toolkits.

array_editor(*args, **traits)
boolean_editor(*args, **traits)
button_editor(*args, **traits)
check_list_editor(*args, **traits)
code_editor(*args, **traits)
color_editor(*args, **traits)
color_trait(*args, **traits)
compound_editor(*args, **traits)
constants()

Returns a dictionary of useful constants.

Currently, the dictionary should have the following key/value pairs:

  • WindowColor’: the standard window background color in the toolkit specific color format.

custom_editor(*args, **traits)
destroy_children(control)

Destroys all of the child controls of a specified GUI toolkit control.

destroy_control(control)

Destroys a specified GUI toolkit control.

directory_editor(*args, **traits)
dnd_editor(*args, **traits)
drop_editor(*args, **traits)
enum_editor(*args, **traits)
file_editor(*args, **traits)
font_editor(*args, **traits)
font_trait(*args, **traits)
history_editor(*args, **traits)
hook_events(ui, control, events=None, handler=None)

Hooks all specified events for all controls in a UI so that they can be routed to the correct event handler.

html_editor(*args, **traits)
image_editor(*args, **traits)
image_enum_editor(*args, **traits)
image_size(image)

Returns a ( width, height ) tuple containing the size of a specified toolkit image.

instance_editor(*args, **traits)
key_binding_editor(*args, **traits)
key_event_to_name(event)

Converts a keystroke event into a corresponding key name.

kiva_font_trait(*args, **traits)
list_editor(*args, **traits)
list_str_editor(*args, **traits)
null_editor(*args, **traits)
ordered_set_editor(*args, **traits)
plot_editor(*args, **traits)
position(ui)

Positions the associated dialog window on the display.

range_editor(*args, **traits)
rebuild_ui(ui)

Rebuilds a UI after a change to the content of the UI.

rgb_color_editor(*args, **traits)
rgb_color_trait(*args, **traits)
rgba_color_editor(*args, **traits)
rgba_color_trait(*args, **traits)
route_event(ui, event)

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

save_window(ui)

Saves user preference information associated with a UI window.

set_icon(ui)

Sets the icon for the UI window.

set_title(ui)

Sets the title for the UI window.

shell_editor(*args, **traits)
show_help(ui, control)

Shows a Help window for a specified UI and control.

skip_event(event)

Indicates that an event should continue to be processed by the toolkit.

table_editor(*args, **traits)
tabular_editor(*args, **traits)
text_editor(*args, **traits)
title_editor(*args, **traits)
tree_editor(*args, **traits)
tuple_editor(*args, **traits)
ui_editor()
ui_info(ui, parent)

Creates a GUI-toolkit-specific temporary “live update” popup dialog user interface using information from the specified UI object.

ui_live(ui, parent)

Creates a GUI-toolkit-specific non-modal “live update” window user interface using information from the specified UI object.

ui_livemodal(ui, parent)

Creates a GUI-toolkit-specific modal “live update” dialog user interface using information from the specified UI object.

ui_modal(ui, parent)

Creates a GUI-toolkit-specific modal dialog user interface using information from the specified UI object.

ui_nonmodal(ui, parent)

Creates a GUI-toolkit-specific non-modal dialog user interface using information from the specified UI object.

ui_panel(ui, parent)

Creates a GUI-toolkit-specific panel-based user interface using information from the specified UI object.

ui_popover(ui, parent)

Creates a GUI-toolkit-specific temporary “live update” popup dialog user interface using information from the specified UI object.

ui_popup(ui, parent)

Creates a GUI-toolkit-specific temporary “live update” popup dialog user interface using information from the specified UI object.

ui_subpanel(ui, parent)

Creates a GUI-toolkit-specific subpanel-based user interface using information from the specified UI object.

ui_wizard(ui, parent)

Creates a GUI-toolkit-specific wizard dialog user interface using information from the specified UI object.

value_editor(*args, **traits)
view_application(context, view, kind=None, handler=None, id='', scrollable=None, args=None)
Creates a GUI-toolkit-specific modal dialog user interface that

runs as a complete application using information from the specified View object.

Parameters
  • 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.

  • view (view or string) – A View object that defines a user interface for editing trait attribute values.

  • kind (string) – The type of user interface window to create. See the traitsui.view.kind_trait trait for values and their meanings. If kind is unspecified or None, the kind attribute of the View object is used.

  • 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.

traitsui.toolkit.assert_toolkit_import(names)

Raise an error if a toolkit with the given name should not be allowed to be imported.

traitsui.toolkit.toolkit(*toolkits)

Selects and returns a low-level GUI toolkit.

Use this function to get a reference to the current toolkit.

Parameters

*toolkits (strings) – Toolkit names to try if toolkit not already selected. If not supplied, will try all traitsui.toolkits entry points until a match is found.

Returns

Appropriate concrete Toolkit subclass for selected toolkit.

Return type

toolkit

Raises
  • TraitError – If no working toolkit is found.

  • RuntimeError – If no ETSConfig.toolkit is set but the toolkit cannot be loaded for some reason.

traitsui.toolkit.toolkit_object(name, raise_exceptions=False)

Return the toolkit specific object with the given name.

Parameters
  • name (str) – The relative module path and the object name separated by a colon.

  • raise_exceptions (bool) – Whether or not to raise an exception if the name cannot be imported.

Raises
  • TraitError – If no working toolkit is found.

  • RuntimeError – If no ETSConfig.toolkit is set but the toolkit cannot be loaded for some reason. This is also raised if raise_exceptions is True the backend does not implement the desired object.