当前位置: 首页>>代码示例>>Python>>正文


Python settings.get_theming_attribute函数代码示例

本文整理汇总了Python中settings.settings.get_theming_attribute函数的典型用法代码示例。如果您正苦于以下问题:Python get_theming_attribute函数的具体用法?Python get_theming_attribute怎么用?Python get_theming_attribute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_theming_attribute函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, message, even=True):
        """
        :param message: a message
        :type message: alot.db.Message
        :param even: even entry in a pile of messages? Used for theming.
        :type even: bool
        """
        self.message = message
        self.even = even
        if even:
            attr = settings.get_theming_attribute('thread', 'summary_even')
        else:
            attr = settings.get_theming_attribute('thread', 'summary_odd')
        cols = []

        sumstr = self.__str__()
        txt = urwid.Text(sumstr)
        cols.append(txt)

        thread_tags = message.get_thread().get_tags(intersection=True)
        outstanding_tags = set(message.get_tags()).difference(thread_tags)
        tag_widgets = [TagWidget(t) for t in outstanding_tags]
        tag_widgets.sort(tag_cmp, lambda tag_widget: tag_widget.translated)
        for tag_widget in tag_widgets:
            if not tag_widget.hidden:
                cols.append(('fixed', tag_widget.width(), tag_widget))
        focus_att = settings.get_theming_attribute('thread', 'summary_focus')
        line = urwid.AttrMap(urwid.Columns(cols, dividechars=1), attr,
                             focus_att)
        urwid.WidgetWrap.__init__(self, line)
开发者ID:laarmen,项目名称:alot,代码行数:30,代码来源:widgets.py

示例2: rebuild

    def rebuild(self):
        if self.isinitialized:
            focusposition = self.taglist.get_focus()[1]
        else:
            focusposition = 0
            self.isinitialized = True

        lines = list()
        displayedtags = sorted(filter(self.filtfun, self.tags),
                               key=unicode.lower)
        for (num, b) in enumerate(displayedtags):
            if (num % 2) == 0:
                attr = settings.get_theming_attribute('taglist', 'line_even')
            else:
                attr = settings.get_theming_attribute('taglist', 'line_odd')
            focus_att = settings.get_theming_attribute('taglist', 'line_focus')

            tw = TagWidget(b, attr, focus_att)
            rows = [('fixed', tw.width(), tw)]
            if tw.hidden:
                rows.append(urwid.Text(b + ' [hidden]'))
            elif tw.translated is not b:
                rows.append(urwid.Text('(%s)' % b))
            line = urwid.Columns(rows, dividechars=1)
            line = urwid.AttrMap(line, attr, focus_att)
            lines.append(line)

        self.taglist = urwid.ListBox(urwid.SimpleListWalker(lines))
        self.body = self.taglist

        self.taglist.set_focus(focusposition % len(displayedtags))
开发者ID:Profpatsch,项目名称:alot,代码行数:31,代码来源:buffers.py

示例3: __init__

 def __init__(self, attachment, selectable=True):
     self._selectable = selectable
     self.attachment = attachment
     if not isinstance(attachment, Attachment):
         self.attachment = Attachment(self.attachment)
     att = settings.get_theming_attribute("thread", "attachment")
     focus_att = settings.get_theming_attribute("thread", "attachment_focus")
     widget = urwid.AttrMap(urwid.Text(self.attachment.__str__()), att, focus_att)
     urwid.WidgetWrap.__init__(self, widget)
开发者ID:kazuoteramoto,项目名称:alot,代码行数:9,代码来源:widgets.py

示例4: _get_theme

 def _get_theme(self, component, focus=False):
     path = ["search", "threadline", component]
     if focus:
         path.append("focus")
     else:
         path.append("normal")
     return settings.get_theming_attribute(path)
开发者ID:kazuoteramoto,项目名称:alot,代码行数:7,代码来源:widgets.py

示例5: __init__

    def __init__(self, dbman, initialcmd):
        """
        :param dbman: :class:`~alot.db.DBManager`
        :param initialcmd: commandline applied after setting up interface
        :type initialcmd: str
        :param colourmode: determines which theme to chose
        :type colourmode: int in [1,16,256]
        """
        self.dbman = dbman

        colourmode = int(settings.get('colourmode'))
        logging.info('setup gui in %d colours' % colourmode)
        global_att = settings.get_theming_attribute('global', 'body')
        self.mainframe = urwid.Frame(urwid.SolidFill())
        self.mainframe_themed = urwid.AttrMap(self.mainframe, global_att)
        self.inputwrap = InputWrap(self, self.mainframe_themed)
        self.mainloop = urwid.MainLoop(self.inputwrap,
                handle_mouse=False,
                event_loop=urwid.TwistedEventLoop(),
                unhandled_input=self.unhandeled_input)
        self.mainloop.screen.set_terminal_properties(colors=colourmode)

        self.show_statusbar = settings.get('show_statusbar')
        self.notificationbar = None
        self.mode = 'global'
        self.commandprompthistory = []

        logging.debug('fire first command')
        self.apply_command(initialcmd)
        self.mainloop.run()
开发者ID:t-8ch,项目名称:alot,代码行数:30,代码来源:ui.py

示例6: build_statusbar

    def build_statusbar(self):
        """construct and return statusbar widget"""
        info = {}
        cb = self.current_buffer
        btype = None

        if cb is not None:
            info = cb.get_info()
            btype = cb.modename
            info['buffer_no'] = self.buffers.index(cb)
            info['buffer_type'] = btype
        info['total_messages'] = self.dbman.count_messages('*')
        info['pending_writes'] = len(self.dbman.writequeue)
        info['input_queue'] = ' '.join(self.input_queue)

        lefttxt = righttxt = u''
        if cb is not None:
            lefttxt, righttxt = settings.get(btype + '_statusbar', (u'', u''))
            lefttxt = string_decode(lefttxt, 'UTF-8')
            lefttxt = lefttxt.format(**info)
            righttxt = string_decode(righttxt, 'UTF-8')
            righttxt = righttxt.format(**info)

        footerleft = urwid.Text(lefttxt, align='left')
        pending_writes = len(self.dbman.writequeue)
        if pending_writes > 0:
            righttxt = ('|' * pending_writes) + ' ' + righttxt
        footerright = urwid.Text(righttxt, align='right')
        columns = urwid.Columns([
            footerleft,
            ('fixed', len(righttxt), footerright)])
        footer_att = settings.get_theming_attribute('global', 'footer')
        return urwid.AttrMap(columns, footer_att)
开发者ID:geier,项目名称:alot,代码行数:33,代码来源:ui.py

示例7: build_statusbar

    def build_statusbar(self):
        """construct and return statusbar widget"""
        info = {}
        cb = self.current_buffer
        btype = None

        if cb is not None:
            info = cb.get_info()
            btype = cb.modename
            info["buffer_no"] = self.buffers.index(cb)
            info["buffer_type"] = btype
        info["total_messages"] = self.dbman.count_messages("*")
        info["pending_writes"] = len(self.dbman.writequeue)

        lefttxt = righttxt = u""
        if cb is not None:
            lefttxt, righttxt = settings.get(btype + "_statusbar", (u"", u""))
            lefttxt = string_decode(lefttxt, "UTF-8")
            lefttxt = lefttxt.format(**info)
            righttxt = string_decode(righttxt, "UTF-8")
            righttxt = righttxt.format(**info)

        footerleft = urwid.Text(lefttxt, align="left")
        pending_writes = len(self.dbman.writequeue)
        if pending_writes > 0:
            righttxt = ("|" * pending_writes) + " " + righttxt
        footerright = urwid.Text(righttxt, align="right")
        columns = urwid.Columns([footerleft, ("fixed", len(righttxt), footerright)])
        footer_att = settings.get_theming_attribute("global", "footer")
        return urwid.AttrMap(columns, footer_att)
开发者ID:mturquette,项目名称:alot,代码行数:30,代码来源:ui.py

示例8: _build_lines

 def _build_lines(self, lines):
     max_key_len = 1
     headerlines = []
     key_att = settings.get_theming_attribute('thread', 'header_key')
     value_att = settings.get_theming_attribute('thread', 'header_value')
     #calc max length of key-string
     for key, value in lines:
         if len(key) > max_key_len:
             max_key_len = len(key)
     for key, value in lines:
         ##todo : even/odd
         keyw = ('fixed', max_key_len + 1,
                 urwid.Text((key_att, key)))
         valuew = urwid.Text((value_att, value))
         line = urwid.Columns([keyw, valuew])
         headerlines.append(line)
     return headerlines
开发者ID:laarmen,项目名称:alot,代码行数:17,代码来源:widgets.py

示例9: choice

    def choice(self, message, choices={'y': 'yes', 'n': 'no'},
               select=None, cancel=None, msg_position='above'):
        """
        prompt user to make a choice.

        :param message: string to display before list of choices
        :type message: unicode
        :param choices: dict of possible choices
        :type choices: dict: keymap->choice (both str)
        :param select: choice to return if enter/return is hit. Ignored if set
                       to `None`.
        :type select: str
        :param cancel: choice to return if escape is hit. Ignored if set to
                       `None`.
        :type cancel: str
        :param msg_position: determines if `message` is above or left of the
                             prompt. Must be `above` or `left`.
        :type msg_position: str
        :rtype:  :class:`twisted.defer.Deferred`
        """
        assert select in choices.values() + [None]
        assert cancel in choices.values() + [None]
        assert msg_position in ['left', 'above']

        d = defer.Deferred()  # create return deferred
        oldroot = self.mainloop.widget

        def select_or_cancel(text):
            self.mainloop.widget = oldroot
            self._passall = False
            d.callback(text)

        # set up widgets
        msgpart = urwid.Text(message)
        choicespart = ChoiceWidget(choices, callback=select_or_cancel,
                                   select=select, cancel=cancel)

        # build widget
        if msg_position == 'left':
            both = urwid.Columns(
                [
                    ('fixed', len(message), msgpart),
                    ('weight', 1, choicespart),
                ], dividechars=1)
        else:  # above
            both = urwid.Pile([msgpart, choicespart])
        att = settings.get_theming_attribute('global', 'prompt')
        both = urwid.AttrMap(both, att, att)

        # put promptwidget as overlay on main widget
        overlay = urwid.Overlay(both, oldroot,
                                ('fixed left', 0),
                                ('fixed right', 0),
                                ('fixed bottom', 1),
                                None)
        self.mainloop.widget = overlay
        self._passall = True
        return d  # return deferred
开发者ID:geier,项目名称:alot,代码行数:58,代码来源:ui.py

示例10: prompt

    def prompt(self, prefix, text=u'', completer=None, tab=0, history=[]):
        """
        prompt for text input.
        This returns a :class:`~twisted.defer.Deferred` that calls back with
        the input string.

        :param prefix: text to print before the input field
        :type prefix: str
        :param text: initial content of the input field
        :type text: str
        :param completer: completion object to use
        :type completer: :meth:`alot.completion.Completer`
        :param tab: number of tabs to press initially
                    (to select completion results)
        :type tab: int
        :param history: history to be used for up/down keys
        :type history: list of str
        :rtype: :class:`twisted.defer.Deferred`
        """
        d = defer.Deferred()  # create return deferred
        oldroot = self.mainloop.widget

        def select_or_cancel(text):
            # restore main screen and invoke callback
            # (delayed return) with given text
            self.mainloop.widget = oldroot
            self._passall = False
            d.callback(text)

        prefix = prefix + settings.get('prompt_suffix')

        # set up widgets
        leftpart = urwid.Text(prefix, align='left')
        editpart = CompleteEdit(completer, on_exit=select_or_cancel,
                                edit_text=text, history=history)

        for i in range(tab):  # hit some tabs
            editpart.keypress((0,), 'tab')

        # build promptwidget
        both = urwid.Columns(
            [
                ('fixed', len(prefix), leftpart),
                ('weight', 1, editpart),
            ])
        att = settings.get_theming_attribute('global', 'prompt')
        both = urwid.AttrMap(both, att)

        # put promptwidget as overlay on main widget
        overlay = urwid.Overlay(both, oldroot,
                                ('fixed left', 0),
                                ('fixed right', 0),
                                ('fixed bottom', 1),
                                None)
        self.mainloop.widget = overlay
        self._passall = True
        return d  # return deferred
开发者ID:lzap,项目名称:alot,代码行数:57,代码来源:ui.py

示例11: _get_header_widget

    def _get_header_widget(self):
        """creates/returns the widget that displays the mail header"""
        all_shown = self._all_headers == self._displayed_headers

        if self.headerw and (self.show_all_headers == all_shown):
            return self.headerw

        if self.show_all_headers:
            self._displayed_headers = self._all_headers
        else:
            self._displayed_headers = self._filtered_headers

        mail = self.message.get_email()
        # normalize values if only filtered list is shown
        norm = not (self._displayed_headers == self._all_headers)

        # build lines
        lines = []
        for key in self._displayed_headers:
            if key in mail:
                if key.lower() in ["cc", "bcc", "to"]:
                    values = mail.get_all(key)
                    values = [decode_header(v, normalize=norm) for v in values]
                    lines.append((key, ", ".join(values)))
                else:
                    for value in mail.get_all(key):
                        dvalue = decode_header(value, normalize=norm)
                        lines.append((key, dvalue))

        key_att = settings.get_theming_attribute("thread", "header_key")
        value_att = settings.get_theming_attribute("thread", "header_value")
        cols = [HeadersList(lines, key_att, value_att)]
        bc = list()
        if self.depth:
            cols.insert(0, self._get_spacer(self.bars_at[1:]))
            bc.append(0)
            cols.insert(1, self._get_arrowhead_aligner())
            bc.append(1)
        self.headerw = urwid.Columns(cols, box_columns=bc)
        return self.headerw
开发者ID:kazuoteramoto,项目名称:alot,代码行数:40,代码来源:widgets.py

示例12: __init__

    def __init__(self, dbman, initialcmd):
        """
        :param dbman: :class:`~alot.db.DBManager`
        :param initialcmd: commandline applied after setting up interface
        :type initialcmd: str
        :param colourmode: determines which theme to chose
        :type colourmode: int in [1,16,256]
        """
        # store database manager
        self.dbman = dbman
        # define empty notification pile
        self._notificationbar = None
        # should we show a status bar?
        self._show_statusbar = settings.get("show_statusbar")
        # pass keypresses to the root widget and never interpret bindings
        self._passall = False
        # indicates "input lock": only focus move commands are interpreted
        self._locked = False
        self._unlock_callback = None  # will be called after input lock ended
        self._unlock_key = None  # key that ends input lock

        # alarm handle for callback that clears input queue (to cancel alarm)
        self._alarm = None

        # create root widget
        global_att = settings.get_theming_attribute("global", "body")
        mainframe = urwid.Frame(urwid.SolidFill())
        self.root_widget = urwid.AttrMap(mainframe, global_att)

        # set up main loop
        self.mainloop = urwid.MainLoop(
            self.root_widget,
            handle_mouse=False,
            event_loop=urwid.TwistedEventLoop(),
            unhandled_input=self._unhandeled_input,
            input_filter=self._input_filter,
        )

        # set up colours
        colourmode = int(settings.get("colourmode"))
        logging.info("setup gui in %d colours" % colourmode)
        self.mainloop.screen.set_terminal_properties(colors=colourmode)

        logging.debug("fire first command")
        self.apply_command(initialcmd)

        # start urwids mainloop
        self.mainloop.run()
开发者ID:teythoon,项目名称:alot,代码行数:48,代码来源:ui.py

示例13: choice

    def choice(self, message, choices={"y": "yes", "n": "no"}, select=None, cancel=None, msg_position="above"):
        """
        prompt user to make a choice

        :param message: string to display before list of choices
        :type message: unicode
        :param choices: dict of possible choices
        :type choices: dict: keymap->choice (both str)
        :param select: choice to return if enter/return is hit. Ignored if set
                       to `None`.
        :type select: str
        :param cancel: choice to return if escape is hit. Ignored if set to
                       `None`.
        :type cancel: str
        :param msg_position: determines if `message` is above or left of the
                             prompt. Must be `above` or `left`.
        :type msg_position: str
        :returns: a :class:`twisted.defer.Deferred`
        """
        assert select in choices.values() + [None]
        assert cancel in choices.values() + [None]
        assert msg_position in ["left", "above"]

        d = defer.Deferred()  # create return deferred
        oldroot = self.inputwrap.get_root()

        def select_or_cancel(text):
            self.inputwrap.set_root(oldroot)
            self.inputwrap.select_cancel_only = False
            d.callback(text)

        # set up widgets
        msgpart = urwid.Text(message)
        choicespart = ChoiceWidget(choices, callback=select_or_cancel, select=select, cancel=cancel)

        # build widget
        if msg_position == "left":
            both = urwid.Columns([("fixed", len(message), msgpart), ("weight", 1, choicespart)], dividechars=1)
        else:  # above
            both = urwid.Pile([msgpart, choicespart])
        att = settings.get_theming_attribute("global", "prompt")
        both = urwid.AttrMap(both, att, att)

        # put promptwidget as overlay on main widget
        overlay = urwid.Overlay(both, oldroot, ("fixed left", 0), ("fixed right", 0), ("fixed bottom", 1), None)
        self.inputwrap.set_root(overlay)
        self.inputwrap.select_cancel_only = True
        return d  # return deferred
开发者ID:mturquette,项目名称:alot,代码行数:48,代码来源:ui.py

示例14: prompt

    def prompt(self, prefix, text=u"", completer=None, tab=0, history=[]):
        """prompt for text input

        :param prefix: text to print before the input field
        :type prefix: str
        :param text: initial content of the input field
        :type text: str
        :param completer: completion object to use
        :type completer: :meth:`alot.completion.Completer`
        :param tab: number of tabs to press initially
                    (to select completion results)
        :type tab: int
        :param history: history to be used for up/down keys
        :type history: list of str
        :returns: a :class:`twisted.defer.Deferred`
        """
        d = defer.Deferred()  # create return deferred
        oldroot = self.inputwrap.get_root()

        def select_or_cancel(text):
            # restore main screen and invoke callback
            # (delayed return) with given text
            self.inputwrap.set_root(oldroot)
            self.inputwrap.select_cancel_only = False
            d.callback(text)

        prefix = prefix + settings.get("prompt_suffix")

        # set up widgets
        leftpart = urwid.Text(prefix, align="left")
        editpart = CompleteEdit(completer, on_exit=select_or_cancel, edit_text=text, history=history)

        for i in range(tab):  # hit some tabs
            editpart.keypress((0,), "tab")

        # build promptwidget
        both = urwid.Columns([("fixed", len(prefix), leftpart), ("weight", 1, editpart)])
        att = settings.get_theming_attribute("global", "prompt")
        both = urwid.AttrMap(both, att)

        # put promptwidget as overlay on main widget
        overlay = urwid.Overlay(both, oldroot, ("fixed left", 0), ("fixed right", 0), ("fixed bottom", 1), None)
        self.inputwrap.set_root(overlay)
        self.inputwrap.select_cancel_only = True
        return d  # return deferred
开发者ID:mturquette,项目名称:alot,代码行数:45,代码来源:ui.py

示例15: build_statusbar

 def build_statusbar(self):
     """construct and return statusbar widget"""
     if self.current_buffer is not None:
         idx = self.buffers.index(self.current_buffer)
         lefttxt = '%d: %s' % (idx, self.current_buffer)
     else:
         lefttxt = '[no buffers]'
     footerleft = urwid.Text(lefttxt, align='left')
     righttxt = 'total messages: %d' % self.dbman.count_messages('*')
     pending_writes = len(self.dbman.writequeue)
     if pending_writes > 0:
         righttxt = ('|' * pending_writes) + ' ' + righttxt
     footerright = urwid.Text(righttxt, align='right')
     columns = urwid.Columns([
         footerleft,
         ('fixed', len(righttxt), footerright)])
     footer_att = settings.get_theming_attribute('global', 'footer')
     return urwid.AttrMap(columns, footer_att)
开发者ID:laarmen,项目名称:alot,代码行数:18,代码来源:ui.py


注:本文中的settings.settings.get_theming_attribute函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。