Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

fixes issue #87 #88

Merged
merged 4 commits into from

3 participants

@itziakos
Owner

This pr fixes issue #87 and provides a tests for regression checking.

pyface/tasks/task_layout.py
@@ -3,7 +3,7 @@
import sys
# Enthought library imports.
-from traits.api import Either, Enum, HasStrictTraits, Int, List, Str, This
+from traits.api import Either, Enum, HasStrictTraits, Int, Instance, List, Str, This
@cfarrow Owner
cfarrow added a note

This is no longer used.

@itziakos Owner
itziakos added a note

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
pyface/tasks/task_layout.py
@@ -132,7 +132,8 @@ class Splitter(LayoutContainer):
# The sub-items of the splitter, which are PaneItems, Tabbed layouts, and
# other Splitters.
- items = List(Either(PaneItem, Tabbed, This), pretty_skip=True)
+ items = List(Either(PaneItem, Tabbed,
+ Instance('pyface.tasks.api.Splitter')), pretty_skip=True)
@cfarrow Owner
cfarrow added a note

This should refer to pyface.tasks.task_layout.Splitter to avoid unnecessarily importing the api module.

@itziakos Owner
itziakos added a note

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@pberkes
Owner

LGTM, modulo Chris' comments

@pberkes
Owner

:+1:

@cfarrow cfarrow merged commit 30d12d5 into master
@cfarrow cfarrow deleted the fix-issue-87 branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 31, 2013
  1. @itziakos

    fixes issue #87

    itziakos authored
Commits on Jun 4, 2013
  1. @itziakos

    change instance string

    itziakos authored
  2. @itziakos

    pyflakes

    itziakos authored
  3. @itziakos

    pep8

    itziakos authored
This page is out of date. Refresh to see the latest.
Showing with 54 additions and 14 deletions.
  1. +19 −14 pyface/tasks/task_layout.py
  2. +35 −0 pyface/tasks/tests/test_task_layout.py
View
33 pyface/tasks/task_layout.py
@@ -3,7 +3,7 @@
import sys
# Enthought library imports.
-from traits.api import Either, Enum, HasStrictTraits, Int, List, Str, This
+from traits.api import Either, Enum, HasStrictTraits, Int, Instance, List, Str
class LayoutItem(HasStrictTraits):
@@ -38,7 +38,7 @@ def pstream(self, stream, indent=0, multiline=False):
indent += len(call)
stream.write(call)
- args = [ (None, arg) for arg in self.pargs() ]
+ args = [(None, arg) for arg in self.pargs()]
traits = []
for name, trait in sorted(self.traits().iteritems()):
if not trait.pretty_skip and not trait.transient:
@@ -63,9 +63,9 @@ def pstream(self, stream, indent=0, multiline=False):
stream.write('\n' + indent * ' ')
else:
stream.write(' ')
-
+
stream.write(')')
-
+
class LayoutContainer(LayoutItem):
""" The base class for all layout items that contain other layout items.
@@ -84,7 +84,7 @@ def iterleaves(self):
def pargs(self):
return self.items
-
+
class PaneItem(LayoutItem):
""" A pane in a Task layout.
@@ -98,8 +98,8 @@ class PaneItem(LayoutItem):
# according to its size hint.
width = Int(-1)
- # The height of the pane in pixels. If not specified, the pane will be sized
- # according to its size hint.
+ # The height of the pane in pixels. If not specified, the pane will be
+ # sized according to its size hint.
height = Int(-1)
def __init__(self, id='', **traits):
@@ -107,7 +107,7 @@ def __init__(self, id='', **traits):
self.id = id
def pargs(self):
- return [ self.id ]
+ return [self.id]
class Tabbed(LayoutContainer):
@@ -121,7 +121,7 @@ class Tabbed(LayoutContainer):
# The ID of the TaskPane which is active in layout. If not specified, the
# first pane is active.
active_tab = Either(Str, Int, default='')
-
+
class Splitter(LayoutContainer):
""" A split area in a Task layout.
@@ -132,13 +132,18 @@ class Splitter(LayoutContainer):
# The sub-items of the splitter, which are PaneItems, Tabbed layouts, and
# other Splitters.
- items = List(Either(PaneItem, Tabbed, This), pretty_skip=True)
-
+ items = List(Either(
+ PaneItem,
+ Tabbed,
+ Instance('pyface.tasks.task_layout.Splitter')), pretty_skip=True)
+
+
class HSplitter(Splitter):
""" A convenience class for horizontal splitters.
"""
orientation = Str('horizontal')
+
class VSplitter(Splitter):
""" A convenience class for vertical splitters.
"""
@@ -155,14 +160,14 @@ class DockLayout(LayoutItem):
top = Either(PaneItem, Tabbed, Splitter)
bottom = Either(PaneItem, Tabbed, Splitter)
- # Assignments of dock areas to the window's corners. By default, the top and
- # bottom dock areas extend into both of the top and both of the bottom
+ # Assignments of dock areas to the window's corners. By default, the top
+ # and bottom dock areas extend into both of the top and both of the bottom
# corners, respectively.
top_left_corner = Enum('top', 'left')
top_right_corner = Enum('top', 'right')
bottom_left_corner = Enum('bottom', 'left')
bottom_right_corner = Enum('bottom', 'right')
-
+
class TaskLayout(DockLayout):
""" The layout for a Task.
View
35 pyface/tasks/tests/test_task_layout.py
@@ -0,0 +1,35 @@
+# Standard library imports.
+import unittest
+
+# Enthought library imports.
+from pyface.tasks.api import HSplitter, PaneItem, Tabbed, VSplitter
+
+
+class LayoutItemsTestCase(unittest.TestCase):
+ """ Testing that the layout types play nice with each other.
+
+ This is a regression test for issue #87
+ (https://github.com/enthought/pyface/issues/87)
+
+ """
+
+ def setUp(self):
+ self.items = [HSplitter(), PaneItem(), Tabbed(), VSplitter()]
+
+ def test_hsplitter_items(self):
+ layout = HSplitter(*self.items)
+ self.assertEqual(layout.items, self.items)
+
+ def test_tabbed_items(self):
+ # Tabbed items only accept PaneItems
+ items = [PaneItem(), PaneItem()]
+ layout = Tabbed(*items)
+ self.assertEqual(layout.items, items)
+
+ def test_vsplitter_items(self):
+ layout = VSplitter(*self.items)
+ self.assertEqual(layout.items, self.items)
+
+
+if __name__ == '__main__':
+ unittest.main()
Something went wrong with that request. Please try again.