traitsui.base_panel module

class traitsui.base_panel.BasePanel[source]

Bases: ActionController

Base class for Traits UI panels and dialog boxes.

Concrete subclasses of BasePanel are the Python-side owners of the top-level toolkit control for a UI. They also implement the Pyface ActionController API for menu and toolbar action handling.

add_to_menu(menu_item)[source]

Adds a menu item to the menu bar being constructed.

The bulk of the back-end work is done in Pyface. This code is simply responsible for hooking up radio groups, checkboxes, and enabled status.

This routine is also used to add items to the toolbar, as logic and APIs are identical.

Parameters:

menu_item (toolkit MenuItem) – The Pyface toolkit-level item to add to the menu.

add_to_toolbar(toolbar_item)[source]

Adds a menu item to the menu bar being constructed.

The bulk of the back-end work is done in Pyface. This code is simply responsible for hooking up radio groups, checkboxes, and enabled status.

This simply calls the analagous menu as logic and APIs are identical.

Parameters:

toolbar_item (toolkit Tool) – The Pyface toolkit-level item to add to the toolbar.

can_add_to_menu(action)[source]

Should the toolbar action be defined in the user interface.

This simply calls the analagous menu as logic and APIs are identical.

Parameters:

action (Action) – The Action to add to the toolbar.

Returns:

defined – Whether or not the action should be added to the menu.

Return type:

bool

can_add_to_toolbar(action)[source]

Should the toolbar action be defined in the user interface.

This simply calls the analagous menu as logic and APIs are identical.

Parameters:

action (Action) – The Action to add to the toolbar.

Returns:

defined – Whether or not the action should be added to the toolbar.

Return type:

bool

check_button(buttons, action)[source]

Adds action to the system buttons list for this dialog, if it is not already in the list.

coerce_button(action)[source]

Coerces a string to an Action if necessary.

control = Any()

The top-level toolkit control of the UI.

default_icon()[source]

Return a default icon for a TraitsUI dialog.

is_button(action, name)[source]

Returns whether a specified action button is a system button.

perform(action, event)[source]

Dispatches the action to be handled by the handler.

Parameters:
  • action (Action instance) – The action to perform.

  • event (ActionEvent instance) – The event that triggered the action.

Returns:

result – The result of the action’s perform method (usually None).

Return type:

any

ui = Instance("traitsui.ui.UI")

The UI instance for the view.