def __init__(self, content, key_attr, value_attr, gaps_attr=None): """ :param headerslist: list of key/value pairs to display :type headerslist: list of (str, str) :param key_attr: theming attribute to use for keys :type key_attr: urwid.AttrSpec :param value_attr: theming attribute to use for values :type value_attr: urwid.AttrSpec :param gaps_attr: theming attribute to wrap lines in :type gaps_attr: urwid.AttrSpec """ max_key_len = 1 structure = [] # calc max length of key-string for key, value in content: if len(key) > max_key_len: max_key_len = len(key) for key, value in content: # todo : even/odd keyw = ('fixed', max_key_len + 1, urwid.Text((key_attr, key))) valuew = urwid.Text((value_attr, value)) line = urwid.Columns([keyw, valuew]) if gaps_attr is not None: line = urwid.AttrMap(line, gaps_attr) structure.append((line, None)) SimpleTree.__init__(self, structure)
def __init__(self, content, attr=None, attr_focus=None): """ :class:`SimpleTree` that contains a list of all-level-0 Text widgets for each line in content. """ structure = [] for line in content.splitlines(): structure.append((FocusableText(line, attr, attr_focus), None)) SimpleTree.__init__(self, structure)
def _get_attachments(self): if self._attachments is None: alist = [] for a in self._message.get_attachments(): alist.append((AttachmentWidget(a), None)) if alist: self._attachments = SimpleTree(alist) return self._attachments
def __init__(self, message, odd=True): """ :param message: Messag to display :type message: alot.db.Message :param odd: theme summary widget as if this is an odd line (in the message-pile) :type odd: bool """ self._message = message self._odd = odd self.display_source = False self._summaryw = None self._bodytree = None self._sourcetree = None self.display_all_headers = False self._all_headers_tree = None self._default_headers_tree = None self.display_attachments = True self._attachments = None self._maintree = SimpleTree(self._assemble_structure()) CollapsibleTree.__init__(self, self._maintree)