From 51f109ad69e8d6df00a789aad14f45c0f14f3012 Mon Sep 17 00:00:00 2001 From: Patrick Totzke Date: Mon, 9 Jul 2018 14:38:54 +0100 Subject: deal with cases where part widget can be None this is only possible for "tags" parts, in case the list of tags is empty or all tags are hidden. --- alot/widgets/search.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'alot/widgets/search.py') diff --git a/alot/widgets/search.py b/alot/widgets/search.py index 641aa5e8..71469e27 100644 --- a/alot/widgets/search.py +++ b/alot/widgets/search.py @@ -31,9 +31,19 @@ class ThreadlineWidget(urwid.AttrMap): def rebuild(self): self.thread = self.dbman.get_thread(self.tid) self.widgets = [] - columns = [] self.structure = settings.get_threadline_theming(self.thread) + columns = [] + + # combine width info and widget into an urwid.Column entry + def add_column(width, part): + width_tuple = self.structure[partname]['width'] + if width_tuple[0] == 'weight': + columnentry = width_tuple + (part,) + else: + columnentry = ('fixed', width, part) + columns.append(columnentry) + # create a column for every part of the threadline for partname in self.structure['parts']: # build widget(s) around this part's content and remember them so @@ -42,21 +52,16 @@ class ThreadlineWidget(urwid.AttrMap): width, part = build_tags_part(self.thread.get_tags(), self.structure['tags']['normal'], self.structure['tags']['focus']) - for w in part.widget_list: - self.widgets.append(w) + if part: + add_column(width, part) + for w in part.widget_list: + self.widgets.append(w) else: width, part = build_text_part(partname, self.thread, self.structure[partname]) + add_column(width, part) self.widgets.append(part) - # combine width info and widget into an urwid.Column entry - width_tuple = self.structure[partname]['width'] - if width_tuple[0] == 'weight': - columnentry = width_tuple + (part,) - else: - columnentry = ('fixed', width, part) - columns.append(columnentry) - self.columns = urwid.Columns(columns, dividechars=1) self.original_widget = self.columns -- cgit v1.2.3