From 349c5b2a62035327399b98c280e60ccc9348dfa6 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Mon, 26 May 2014 15:00:36 -0700 Subject: [PATCH] Correct a problem with tables at very small widths Gertty would crash if the screen was narrower than the widest column in a table. This corrects that. Change-Id: Ie0a2c6fae16c7c484edb6724fa5dd5f79065e94f --- gertty/mywid.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gertty/mywid.py b/gertty/mywid.py index e463190..2ad8215 100644 --- a/gertty/mywid.py +++ b/gertty/mywid.py @@ -40,8 +40,9 @@ class FixedButton(urwid.Button): class TableColumn(urwid.Pile): def pack(self, size, focus=False): + maxcol = size[0] mx = max([len(i[0].text) for i in self.contents]) - return (mx+2, len(self.contents)) + return (min(mx+2, maxcol), len(self.contents)) class Table(urwid.WidgetWrap): def __init__(self, headers=[], columns=None):