コード例 #1
0
ファイル: thread.py プロジェクト: ElricleNecro/alot
 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)
コード例 #2
0
 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)
コード例 #3
0
ファイル: thread.py プロジェクト: ElricleNecro/alot
 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)
コード例 #4
0
ファイル: thread.py プロジェクト: tlevine/alot
 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)
コード例 #5
0
    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 = []

        # depending on this config setting, we either add individual lines
        # or the complete context as focusable objects.
        if settings.get('thread_focus_linewise'):
            for line in content.splitlines():
                structure.append((FocusableText(line, attr, attr_focus), None))
        else:
            structure.append((FocusableText(content, attr, attr_focus), None))
        SimpleTree.__init__(self, structure)
コード例 #6
0
    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 = []
        attr_parse = attr

        # depending on this config setting, we either add individual lines
        # or the complete context as focusable objects.
        if settings.get('thread_focus_linewise'):
            for line in content.splitlines():
                attr_parse = parse_text_colour(line)

                if attr_parse is None:
                    attr_parse = attr
                structure.append((ANSIText(line, attr_parse, attr_focus,
                                           ANSI_BACKGROUND), None))
                attr_parse = attr
        else:
            structure.append((ANSIText(content, attr, attr_focus,
                                       ANSI_BACKGROUND), None))
        SimpleTree.__init__(self, structure)