Skip to content

Commit

Permalink
Don't require passing a constraints namespace to layout helpers.
Browse files Browse the repository at this point in the history
  • Loading branch information
jwiggins authored and brett-patterson committed Jun 25, 2014
1 parent 31fe591 commit ab3e95b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
6 changes: 6 additions & 0 deletions enable/layout/layout_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1234,6 +1234,7 @@ def horizontal(*items, **config):
abutments for the given sequence of items.
"""
items = [item.constraints for item in items]
return AbutmentHelper('horizontal', *items, **config)


Expand All @@ -1242,6 +1243,7 @@ def vertical(*items, **config):
abutments for the given sequence of items.
"""
items = [item.constraints for item in items]
return AbutmentHelper('vertical', *items, **config)


Expand All @@ -1250,6 +1252,7 @@ def hbox(*items, **config):
abutments for a given sequence of items.
"""
items = [item.constraints for item in items]
return LinearBoxHelper('horizontal', *items, **config)


Expand All @@ -1258,6 +1261,7 @@ def vbox(*items, **config):
for a given sequence of items.
"""
items = [item.constraints for item in items]
return LinearBoxHelper('vertical', *items, **config)


Expand All @@ -1266,6 +1270,7 @@ def align(anchor, *items, **config):
spacing is allowed.
"""
items = [item.constraints for item in items]
return AlignmentHelper(anchor, *items, **config)


Expand All @@ -1274,6 +1279,7 @@ def grid(*rows, **config):
grid.
"""
rows = [[item.constraints for item in items] for items in rows]
return GridHelper(*rows, **config)


Expand Down
11 changes: 4 additions & 7 deletions examples/enable/constraints_demo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

from enable.api import Component, ComponentEditor, ConstraintsContainer
from enable.layout.layout_helpers import hbox, vbox, align, grid, horizontal
from enable.layout.layout_helpers import hbox, vbox, align, grid, vertical
from traits.api import HasTraits, Any, Instance, List, Property
from traitsui.api import Item, View, HGroup, TabularEditor
from traitsui.tabular_adapter import TabularAdapter
Expand Down Expand Up @@ -55,12 +55,9 @@ def _canvas_default(self):

parent.add(one, two, three, four)
parent.layout_constraints = [
grid([one.constraints, two.constraints],
[three.constraints, four.constraints]),
align('height', one.constraints, two.constraints,
three.constraints, four.constraints),
align('width', one.constraints, two.constraints,
three.constraints, four.constraints),
grid([one, two], [three, four]),
align('height', one, two, three, four),
align('width', one, two, three, four),
]

return parent
Expand Down

0 comments on commit ab3e95b

Please sign in to comment.