enaml.layout.dock_layout

Classes

AreaLayout

A layout object for defining a dock area layout.

DockBarLayout

A layout object for defining a dock bar layout.

DockLayout

The layout object for defining toplevel dock layouts.

DockLayoutOp

A sentinel base class for defining dock layout operations.

DockLayoutValidator

A node visitor which validates a layout.

DockLayoutWarning

A custom user warning for use with dock layouts.

ExtendItem

A layout operation which extends an item in a dock bar.

FloatArea

A layout operation which creates a new floating dock area.

FloatItem

A layout operation which creates a floating dock item.

HSplitLayout

A split layout which defaults to 'horizonal' orientation.

InsertItem

A layout operation which inserts an item into a layout.

InsertBorderItem

A layout operation which inserts an item into an area border.

InsertDockBarItem

A layout operation which inserts an item into a dock bar.

InsertTab

A layout operation which inserts a tab into a tab group.

ItemLayout

A layout object for defining an item layout.

LayoutNode

A base class for defining layout nodes.

RemoveItem

A layout operation which will remove an item from the layout.

RetractItem

A layout operation which retracts an item into a dock bar.

SplitLayout

A layout object for defining split dock layouts.

TabLayout

A layout object for defining tabbed dock layouts.

VSplitLayout

A split layout which defaults to 'vertical' orientation.

class enaml.layout.dock_layout.AreaLayout(item=None, **kwargs)[source]

Bases: LayoutNode

A layout object for defining a dock area layout.

item

The main layout item to include in the area layout.

dock_bars

The dock bar layouts to include in the area layout.

floating

Whether or not the area is floating. A DockLayout should have at most one non-floating area layout.

geometry

The geometry to apply to the area. This is expressed in desktop coordinates and only applies if the area is floating.

linked

Whether or not the area is linked with its floating neighbors. This only has an effect if the area is a floating.

maximized

Whether or not the area is maximized. This only has an effect if the area is a floating.

__init__(item=None, **kwargs)[source]
children()[source]

Get the list of children of the area layout.

class enaml.layout.dock_layout.DockBarLayout(*items, **kwargs)[source]

Bases: LayoutNode

A layout object for defining a dock bar layout.

position

The position of the tool bar in its area. Only one tool bar may occupy a given position at any one time.

items

The list of item layouts to include in the tab layout.

__init__(*items, **kwargs)[source]
children()[source]

Get the list of children of the dock bar layout.

class enaml.layout.dock_layout.DockLayout(*items, **kwargs)[source]

Bases: LayoutNode

The layout object for defining toplevel dock layouts.

items

The layout items to include in the dock layout.

__init__(*items, **kwargs)[source]
children()[source]

Get the list of children of the dock layout.

class enaml.layout.dock_layout.DockLayoutOp[source]

Bases: Atom

A sentinel base class for defining dock layout operations.

class enaml.layout.dock_layout.DockLayoutValidator(available)[source]

Bases: NodeVisitor

A node visitor which validates a layout.

If an irregularity or invalid condition is found in the layout, a warning is emitted. Such conditions can result in undefined layout behavior.

__init__(available)[source]

Initialize a DockLayoutValidator.

Parameters:

available (iterable) – An iterable of strings which represent the available dock item names onto which the layout will be applied. These are used to validate the set of visited ItemLayout instances.

warn(message)[source]

Emit a dock layout warning with the given message.

setup(node)[source]

Setup the dock layout validator.

teardown(node)[source]

Teardown the dock layout validator.

visit_ItemLayout(node)[source]

The visitor method for an ItemLayout node.

visit_TabLayout(node)[source]

The visitor method for a TabLayout node.

visit_SplitLayout(node)[source]

The visitor method for a SplitLayout node.

visit_DockBarLayout(node)[source]

The visitor method for a DockBarLayout node.

visit_AreaLayout(node)[source]

The visitor method for an AreaLayout node.

visit_DockLayout(node)[source]

The visitor method for a DockLayout node.

class enaml.layout.dock_layout.DockLayoutWarning[source]

Bases: UserWarning

A custom user warning for use with dock layouts.

__weakref__

list of weak references to the object (if defined)

class enaml.layout.dock_layout.ExtendItem[source]

Bases: DockLayoutOp

A layout operation which extends an item in a dock bar.

This layout operation will cause the named item to be extended to from its dock bar. If the item does not exist in a dock bar, this operation is a no-op.

item

The name of the dock item to extend from its dock bar.

class enaml.layout.dock_layout.FloatArea[source]

Bases: DockLayoutOp

A layout operation which creates a new floating dock area.

This layout operation will create a new floating dock area using the given area layout specification.

area

The area layout to use when building the new dock area.

class enaml.layout.dock_layout.FloatItem[source]

Bases: DockLayoutOp

A layout operation which creates a floating dock item.

This operation will remove an item from the current layout and insert convert it into a floating item. If the item does not exist, the operation is a no-op.

item

The item layout to use when configuring the floating item.

class enaml.layout.dock_layout.HSplitLayout(*items, **kwargs)[source]

Bases: SplitLayout

A split layout which defaults to ‘horizonal’ orientation.

__init__(*items, **kwargs)[source]
class enaml.layout.dock_layout.InsertItem[source]

Bases: DockLayoutOp

A layout operation which inserts an item into a layout.

This operation will remove an item from the current layout and insert it next to a target item. If the item does not exist, the operation is a no-op.

If the target -

  • is a normally docked item

    The item will be inserted as a new split item.

  • is docked in a tab group

    The item will be inserted as a neighbor of the tab group.

  • is docked in a dock bar

    The item will be appended to the dock bar.

  • is a floating dock item

    A new dock area will be created and the item will be inserted as a new split item.

  • does not exist

    The item is inserted into the border of the primary dock area.

item

The name of the dock item to insert into the layout.

target

The name of the dock item to use as the target location.

position

The position relative to the target at which to insert the item.

class enaml.layout.dock_layout.InsertBorderItem[source]

Bases: DockLayoutOp

A layout operation which inserts an item into an area border.

This operation will remove an item from the current layout and insert it into the border of a dock area. If the item does not exist, the operation is a no-op.

If the target -

  • is a normally docked item

    The item is inserted into the border of the dock area containing the target.

  • is docked in a tab group

    The item is inserted into the border of the dock area containing the tab group.

  • is docked in a dock bar

    The item is inserted into the border of the dock area containing the dock bar.

  • is a floating dock item

    A new dock area will be created and the item will be inserted into the border of the new dock area.

  • does not exist

    The item is inserted into the border of the primary dock area.

item

The name of the dock item to insert into the layout.

target

The name of the dock item to use as the target location.

position

The border position at which to insert the item.

class enaml.layout.dock_layout.InsertDockBarItem[source]

Bases: DockLayoutOp

A layout operation which inserts an item into a dock bar.

This operation will remove an item from the current layout and insert it into a dock bar in a dock area. If the item does not exist, the operation is a no-op.

If the target -

  • is a normally docked item

    The item is inserted into the dock bar of the dock area containing the target.

  • is docked in a tab group

    The item is inserted into the dock bar of the dock area containing the tab group.

  • is docked in a dock bar

    The item is inserted into the dock bar of the dock area containing the dock bar.

  • is a floating dock item

    A new dock area will be created and the item will be inserted into the dock bar of the new dock area.

  • does not exist

    The item is inserted into the dock bar of the primary dock area.

item

The name of the dock item to insert into the layout.

target

The name of the dock item to use as the target location.

position

The dock bar position at which to insert the item.

index

The index at which to insert the dock bar item.

class enaml.layout.dock_layout.InsertTab[source]

Bases: DockLayoutOp

A layout operation which inserts a tab into a tab group.

This operation will remove an item from the current layout and insert it into a tab group in a dock area. If the item does not exist, the operation is a no-op.

If the target -

  • is a normally docked item

    The target and item will be merged into a new tab group using the default tab position.

  • is docked in a tab group

    The item will be inserted into the tab group.

  • is docked in a dock bar

    The item will be appended to the dock bar.

  • is a floating dock item

    A new dock area will be created and the target and item will be merged into a new tab group.

  • does not exist

    The item is inserted into the left border of the primary dock area.

item

The name of the dock item to insert into the tab group.

target

The name of an existing dock item in the tab group of interest.

index

The index at which to insert the dock item.

tab_position

The position of the tabs for a newly created tab group.

class enaml.layout.dock_layout.ItemLayout(name, **kwargs)[source]

Bases: LayoutNode

A layout object for defining an item layout.

name

The name of the DockItem to which this layout item applies.

floating

Whether or not the item is floating. An ItemLayout defined as a toplevel item in a DockLayout should be marked as floating.

geometry

The geometry to apply to the item. This is expressed in desktop coordinates and only applies if the item is floating.

linked

Whether or not the item is linked with its floating neighbors. This value will only have an effect if the item is floating.

maximized

Whether or not the item is maximized. This value will only have effect if the item is floating or docked in a SplitLayout.

__init__(name, **kwargs)[source]
class enaml.layout.dock_layout.LayoutNode[source]

Bases: Atom

A base class for defining layout nodes.

This class provides basic traversal functionality.

children()[source]

Get the children of the node.

Returns:

result – The list of LayoutNode children of the node. The default implementation returns an empty list.

Return type:

list

traverse(depth_first=False)[source]

Yield all of the nodes in the layout, from this node down.

Parameters:

depth_first (bool, optional) – If True, yield the nodes in depth first order. If False, yield the nodes in breadth first order. Defaults to False.

Returns:

result – A generator which yields 2-tuples of (parent, node) for all nodes in the layout.

Return type:

generator

find(kind)[source]

Find the first layout node of the given kind.

Parameters:

kind (type or tuple of types) – The type of the layout node to find.

Returns:

result – The first layout node of the given type in the tree. The search is performed breadth-first.

Return type:

LayoutNode or None

find_all(kind)[source]

Find the layout nodes of the given kind.

Parameters:

kind (type or tuple of types) – The type of the layout nodes to find.

Returns:

result – The list of the layout nodes in the tree which are of the request type. They are ordered breadth-first.

Return type:

list

class enaml.layout.dock_layout.RemoveItem[source]

Bases: DockLayoutOp

A layout operation which will remove an item from the layout.

This layout operation will remove the dock item from the layout and hide it. It can be added back to layout later with one of the other layout operations.

item

The name of the dock item to remove from the layout.

class enaml.layout.dock_layout.RetractItem[source]

Bases: DockLayoutOp

A layout operation which retracts an item into a dock bar.

This layout operation will cause the named item to be retracted into its dock bar. If the item does not exist in a dock bar, this operation is a no-op.

item

The name of the dock item to retract into its dock bar.

class enaml.layout.dock_layout.SplitLayout(*items, **kwargs)[source]

Bases: LayoutNode

A layout object for defining split dock layouts.

orientation

The orientation of the split layout.

sizes

The default sizes to apply to the items in the splitter. If provided, the length must be equal to the number of items.

items

This list of split layout items to include in the split layout.

__init__(*items, **kwargs)[source]
children()[source]

Get the list of children of the split layout.

class enaml.layout.dock_layout.TabLayout(*items, **kwargs)[source]

Bases: LayoutNode

A layout object for defining tabbed dock layouts.

tab_position

The position of the tabs in the tab layout.

index

The index of the currently selected tab.

maximized

Whether or not the tab layout is maximized.

items

The list of item layouts to include in the tab layout.

__init__(*items, **kwargs)[source]
children()[source]

Get the list of children of the tab layout.

class enaml.layout.dock_layout.VSplitLayout(*items, **kwargs)[source]

Bases: SplitLayout

A split layout which defaults to ‘vertical’ orientation.

__init__(*items, **kwargs)[source]