traitsui.editors.table_editor module

Defines the table editor factory for all traits user interface toolkits.

class traitsui.editors.table_editor.BaseTableEditor[source]

Bases: object

Base class for toolkit-specific editors.

add_to_menu(menu_item)[source]

Adds a menu item to the menu bar being constructed.

add_to_toolbar(toolbar_item)[source]

Adds a toolbar item to the toolbar being constructed.

can_add_to_menu(action)[source]

Returns whether the action should be defined in the user interface.

can_add_to_toolbar(action)[source]

Returns whether the toolbar action should be defined in the user interface.

eval_when(condition, object, trait)[source]

Evaluates a condition within a defined context and sets a specified object trait based on the result, which is assumed to be a Boolean.

perform(action, action_event=None)[source]

Performs the action described by a specified Action object.

set_menu_context(selection, object, column)[source]

Call before creating a context menu for a cell, then set self as the controller for the menu.

class traitsui.editors.table_editor.ReversedList(list)[source]

Bases: object

A list whose order is the reverse of its input.

index(value)[source]

Returns the index of the first occurrence of the specified value in the list.

insert(index, value)[source]

Inserts a value at a specified index in the list.

class traitsui.editors.table_editor.TableEditor(*args, **traits)[source]

Bases: EditorFactory

Editor factory for table editors.

alternate_bg_color = Bool(False)

Whether to even-odd alternate the background color. Qt only.

auto_add = Bool(False)

Should a new row automatically be added to the end of the table to allow the user to create new entries? If True, row_factory must be set.

auto_size = Bool(True)

Should the cells of the table automatically size to the optimal size?

cell_bg_color = Color(default=None, allow_none=True)

Color to use for cell backgrounds

cell_color = Color(default=None, allow_none=True)

Color to use for text in cells

cell_font = Font

Font to use for text in cells

cell_read_only_bg_color = Color(default=None, allow_none=True)

Color to use for read-only cell backgrounds

click = Str()

The optional extended trait name of the trait that should be assigned an ( object, column ) tuple when a table cell is clicked on (Note: If you want to receive repeated clicks on the same cell, make sure the trait is defined as an Event):

column_label_height = Int(25)

Height (in pixels) of column labels

columns = List(Instance("traitsui.table_column.TableColumn"))

List of initial table column descriptors

columns_name = Str()

The object trait containing the list of column descriptors

configurable = Bool(True)

Can the user configure the table columns?

dclick = Str()

The optional extended trait name of the trait that should be assigned an ( object, column ) tuple when a table cell is double-clicked on (Note: if you want to receive repeated double-clicks on the same cell, make sure the trait is defined as an Event):

deletable = BoolOrCallable(False)

Are objects deletable from the table?

dock_theme = Any()

The DockWindow graphical theme:

edit_on_first_click = Bool(True)

Should the editor become active after the first click

edit_view = AView(" ")

View to use when editing table items. NOTE: If not specified, the table items are not editable in a separate pane of the editor.

edit_view_handler = Instance(Handler)

The handler to apply to edit_view

edit_view_height = Float(-1.0)

Height to use for the edit view

edit_view_width = Float(-1.0)

Width to use for the edit view

editable = Bool(True)

Is the table editable?

filter = Instance("traitsui.table_filter.TableFilter")

Initial filter that should be applied to the table

filter_name = Str()

The optional extended name of the trait used to specify an external filter for the table data. The value of the trait must either be an instance of TableEditor, a callable that accepts one argument (a table row) and returns True or False to indicate whether the specified object passes the filter or not, or None to indicate that no filter is to be applied:

filtered_indices = Str()

The optional extended name of the trait that the indices of the items currently passing the table filter are synced with:

filters = List(Instance("traitsui.table_filter.TableFilter"))

List of available filters that can be applied to the table

h_size_policy = Enum(

Mirrors the Qt QSizePolicy.Policy attribute, for horizontal and vertical dimensions. For these to be useful, set auto_size to False. If these are None, then the table size policy will not be set in that dimension (for backwards compatibility).

label_bg_color = Color(default=None, allow_none=True)

Color to use for label backgrounds. Some Qt styles (eg. MacOS) ignore this.

label_color = Color(default=None, allow_none=True)

Color to use for text in labels

label_font = Font

Font to use for text in labels

line_color = Color(0xC4C0A9)

Grid line color. Does not work on Qt.

menu = Instance("traitsui.menu.Menu")

Default context menu to display when any cell is right-clicked

menu_name = Str()

Default trait name containg menu

on_dclick = Any()

Called when a table item is double clicked

on_select = Any()

Called when a table item is selected

orientation = Orientation

Layout orientation of the table and its associated editor pane. This attribute applies only if edit_view is not ‘ ‘.

other_columns = List(Instance("traitsui.table_column.TableColumn"))

List of other table column descriptors (not initially displayed)

readonly_editor(ui, object, name, description, parent)[source]

Generates an “editor” that is read-only. Overridden to set the value of the editable trait to False before generating the editor.

reorderable = Bool(False)

Can the user reorder the items in the table?

reverse = Bool(False)

Should the table items be presented in reverse order?

row_factory = Any()

A factory to generate new rows. NOTE: If None, then the user will not be able to add new rows to the table. If not None, then it must be a callable that accepts row_factory_args and row_factory_kw and returns a new object that can be added to the table.

row_factory_args = Tuple()

Arguments to pass to the row_factory callable when a new row is created

row_factory_kw = Dict()

Keyword arguments to pass to the row_factory callable when a new row is created

row_height = Int(0)

The initial height of each row (<= 0 means use default value):

row_label_width = Int(82)

Width (in pixels) of row labels

rows = Int()

The desired number of visible rows in the table

scroll_dy = Range(1, 32)

The vertical scroll increment for the table:

search = Instance("traitsui.table_filter.TableFilter")

Filter object used to allow a user to search the table. NOTE: If left as None, the table will not be searchable.

selected = Str()

The optional extended name of the trait that the current selection is synced with:

selected_indices = Str()

The optional extended trait name of the trait that the indices of the current selection are synced with:

selection_bg_color = Color(default=None, allow_none=True)

Background color of selected item.

selection_color = Color(default=None, allow_none=True)

Color of selected text.

selection_mode = Enum("row", "rows", "column", "columns", "cell", "cells")

The selection mode of the table. The meaning of the various values are as follows:

row

Entire rows are selected. At most one row can be selected at once. This is the default.

rows

Entire rows are selected. More than one row can be selected at once.

column

Entire columns are selected. At most one column can be selected at once.

columns

Entire columns are selected. More than one column can be selected at once.

cell

Single cells are selected. Only one cell can be selected at once.

cells

Single cells are selected. More than one cell can be selected at once.

show_column_labels = Bool(True)

Show column labels?

show_lines = Bool(True)

Should grid lines be shown on the table?

show_row_labels = Bool(False)

Show row labels?

show_toolbar = Bool(False)

Should the toolbar be displayed? (Note that False will override settings such as ‘configurable’, etc., and is a quick way to prevent the toolbar from being displayed; but True will not cause a toolbar to appear if one would not otherwise have been displayed)

sort_model = Bool(False)

Does sorting affect the model (vs. just the view)?

sortable = Bool(True)

Is the table sortable by clicking on the column headers?

table_view_factory = Callable()

Hooks for replacing parts of the implementation.

update_filter_name = Str()

The optional extended trait name of the trait used to notify that the filter has changed and the displayed objects should be updated. It should be an Event.

traitsui.editors.table_editor.ToolkitEditorFactory

alias of TableEditor