diff options
author | Ian Ward <ian@excess.org> | 2012-09-21 17:40:10 -0400 |
---|---|---|
committer | Ian Ward <ian@excess.org> | 2012-09-21 17:40:10 -0400 |
commit | 49512cbedb38bfe42056d5bc6deaec90e6d23664 (patch) | |
tree | 31e1953162497a98fc2b50e2cae9dbcf4a7a7f19 /urwid | |
parent | b4fed14f3a529f7dc9b3be4d4e7bcd6eaa4c0254 (diff) | |
download | urwid-49512cbedb38bfe42056d5bc6deaec90e6d23664.tar.gz |
Pile, Overlay, Columns fixes for more widget-squishing tests
--HG--
branch : feature-sphinx
Diffstat (limited to 'urwid')
-rw-r--r-- | urwid/canvas.py | 12 | ||||
-rwxr-xr-x | urwid/container.py | 18 |
2 files changed, 18 insertions, 12 deletions
diff --git a/urwid/canvas.py b/urwid/canvas.py index 23ec000..593b252 100644 --- a/urwid/canvas.py +++ b/urwid/canvas.py @@ -755,12 +755,12 @@ class CompositeCanvas(Canvas): left_shards = [] right_shards = [] - if left: + if left > 0: left_shards = [shards_trim_sides(side_shards, 0, left)] - if right: - right_shards = [shards_trim_sides(side_shards, - left + width, right)] - + if right > 0: + right_shards = [shards_trim_sides(side_shards, + max(0, left + width), right)] + if not self.rows(): middle_shards = [] elif left or right: @@ -1022,7 +1022,7 @@ def shards_trim_sides(shards, left, cols): """ Return shards with starting from column left and cols total width. """ - assert left >= 0 and cols > 0 + assert left >= 0 and cols > 0, (left, cols) shard_tail = [] new_shards = [] right = left + cols diff --git a/urwid/container.py b/urwid/container.py index 951d324..95bda44 100755 --- a/urwid/container.py +++ b/urwid/container.py @@ -732,13 +732,16 @@ class Overlay(Widget, WidgetContainerMixin, WidgetContainerListContentsMixin): left, right, top, bottom = self.calculate_padding_filler(size, focus) bottom_c = self.bottom_w.render(size) + if not bottom_c.cols() or not bottom_c.rows(): + return CompositeCanvas(bottom_c) + top_c = self.top_w.render( self.top_w_size(size, left, right, top, bottom), focus) top_c = CompositeCanvas(top_c) - if left<0 or right<0: - top_c.pad_trim_left_right(min(0,left), min(0,right)) - if top<0 or bottom<0: - top_c.pad_trim_top_bottom(min(0,top), min(0,bottom)) + if left < 0 or right < 0: + top_c.pad_trim_left_right(min(0, left), min(0, right)) + if top < 0 or bottom < 0: + top_c.pad_trim_top_bottom(min(0, top), min(0, bottom)) return CanvasOverlay(top_c, bottom_c, left, top) @@ -1486,8 +1489,8 @@ class Pile(Widget, WidgetContainerMixin, WidgetContainerListContentsMixin): return SolidCanvas(" ", size[0], (size[1:]+(0,))[0]) out = CanvasCombine(combinelist) - if len(size) == 2 and size[1] < out.rows(): - # flow/fixed widgets rendered too large + if len(size) == 2 and size[1] != out.rows(): + # flow/fixed widgets rendered too large/small out = CompositeCanvas(out) out.pad_trim_top_bottom(0, size[1] - out.rows()) return out @@ -2045,6 +2048,9 @@ class Columns(Widget, WidgetContainerMixin, WidgetContainerListContentsMixin): mc += self.dividechars l.append((canv, i, self.focus_position == i, mc)) + if not l: + return SolidCanvas(" ", size[0], (size[1:]+(0,))[0]) + canv = CanvasJoin(l) if canv.cols() < size[0]: canv.pad_trim_left_right(0, size[0] - canv.cols()) |