From b74ba817eaf2d5c5be89515012053fab8013d645 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sat, 18 Feb 2012 21:59:02 +1300 Subject: [PATCH] Side-step a bug in Urwid < 1.0 Urwid barfs when given a fixed-size column of width zero. --- libmproxy/console/common.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/libmproxy/console/common.py b/libmproxy/console/common.py index 5f80c250d..fbeb83d74 100644 --- a/libmproxy/console/common.py +++ b/libmproxy/console/common.py @@ -43,20 +43,20 @@ def format_keyvals(lst, key="key", val="text", indent=0): if kv is None: ret.append(urwid.Text("")) else: - ret.append( - urwid.Columns( - [ - ("fixed", indent, urwid.Text("")), - ( - "fixed", - maxk, - urwid.Text([(key, kv[0] or "")]) - ), - urwid.Text([(val, kv[1])]) - ], - dividechars = 2 - ) - ) + cols = [] + # This cumbersome construction process is here for a reason: + # Urwid < 1.0 barfs if given a fixed size column of size zero. + if indent: + cols.append(("fixed", indent, urwid.Text(""))) + cols.extend([ + ( + "fixed", + maxk, + urwid.Text([(key, kv[0] or "")]) + ), + urwid.Text([(val, kv[1])]) + ]) + ret.append(urwid.Columns(cols, dividechars = 2)) return ret