Python urwid 模块,SelectableIcon() 实例源码

我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用urwid.SelectableIcon()

项目:mongoaudit    作者:Exploit-install    | 项目源码 | 文件源码
def get_content(text):
        return urwid.Pile([urwid.SelectableIcon(
            s, 0) if i == 0 else urwid.Text(s) for i, s in enumerate(text)])
项目:sshchan    作者:einchan    | 项目源码 | 文件源码
def __init__(self, caption, callback, data):
        super(CleanButton, self).__init__(caption, callback, data)
        self._w = ur.SelectableIcon(caption, 0)
项目:mongoaudit    作者:stampery    | 项目源码 | 文件源码
def get_content(text):
        return urwid.Pile([urwid.SelectableIcon(
            s, 0) if i == 0 else urwid.Text(s) for i, s in enumerate(text)])
项目:bbj    作者:desvox    | 项目源码 | 文件源码
def cute_button(label, callback=None, data=None):
    """
    Urwid's default buttons are shit, and they have ugly borders.
    This function returns buttons that are a bit easier to love.
    """
    button = urwid.Button("", callback, data)
    super(urwid.Button, button).__init__(
        urwid.SelectableIcon(label))
    return button
项目:mccurse    作者:khardix    | 项目源码 | 文件源码
def __init__(self, mod: Mod, *callbacks: Iterable[ModItemCallback]):
            """Wrap mod in the set of display widgets.

            Keyword arguments:
                mod: The :class:`Mod` to be wrapped.
                callbacks: The functions to be called when this object
                    is selected.
            """

            btn_prefix = '  ? '

            # Construct button (the selectable part)
            btn = urwid.Button('')
            btn._w = urwid.AttrMap(
                urwid.SelectableIcon([btn_prefix, mod.name], 2),
                'title', 'title_focus',
            )
            for callback in callbacks:
                urwid.connect_signal(btn, 'click', callback, user_args=[mod])

            # Construct the mod summary
            text = urwid.Padding(
                urwid.AttrMap(urwid.Text(mod.summary), 'description'),
                left=len(btn_prefix)*2,
            )

            pile = btn, text
            super().__init__(pile)
项目:doubanfm-py    作者:nekocode    | 项目源码 | 文件源码
def __init__(self, song, on_pressed_callback, index=0):
        super(SongButton, self).__init__('', on_pressed_callback)
        self.index = index
        self.song = song
        self.is_playing = False

        self._text = urwid.SelectableIcon(
            u'• %s - %s' % (song.title, song.artist),
            cursor_position=0)
        self._w = urwid.AttrMap(self._text, None, focus_map='reversed')
        self.set_is_playing(self.is_playing)

    # ????????