Python urwid.SelectableIcon() Examples

The following are 12 code examples of urwid.SelectableIcon(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module urwid , or try the search function .
Example #1
Source File: main.py    From bbj with MIT License 5 votes vote down vote up
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 
Example #2
Source File: viewer.py    From profiling with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def get_mark(self):
        """Gets an expanded, collapsed, or leaf icon."""
        if self.is_leaf:
            char = self.icon_chars[2]
        else:
            char = self.icon_chars[int(self.expanded)]
        return urwid.SelectableIcon(('mark', char), 0) 
Example #3
Source File: quick_switcher.py    From sclack with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, icon, title, id):
        markup = [' ', icon, ' ', title]
        self.id = id
        super(QuickSwitcherItem, self).__init__(
            urwid.SelectableIcon(markup),
            None,
            {
                None: 'active_quick_switcher_item',
                'quick_search_presence_active': 'quick_search_active_focus',
                'quick_search_presence_away': 'active_quick_switcher_item'
            }
        ) 
Example #4
Source File: components.py    From sclack with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, id, name, is_private=False, is_selected=False):
        self.id = id
        self.name = name
        self.is_private = is_private
        attr_map = 'inactive'
        if is_selected:
            attr_map = 'selected_channel'
        self.last_time_clicked = None
        self.unread = 0
        self.is_selected = is_selected
        self.body = urwid.SelectableIcon(self.get_markup(0))

        super(Channel, self).__init__(self.body, attr_map, 'active_channel') 
Example #5
Source File: components.py    From sclack with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, id, name, user, you=False, unread=0, is_selected=False):
        self.id = id
        self.user = user
        self.name = name
        self.you = you
        self.presence = 'away'
        self.unread = unread
        self.body = urwid.SelectableIcon(self.get_markup())
        self.is_selected = is_selected

        attr_map = 'inactive'
        if is_selected:
            attr_map = 'selected_channel'

        super(Dm, self).__init__(self.body, attr_map, 'active_channel') 
Example #6
Source File: components.py    From sclack with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, number, name):
        separator = ('inactive', format(get_icon('divider')))
        self.number = number
        self.text = ' {}: {} '.format(number, name)
        self.body = urwid.SelectableIcon([self.text, separator])
        self.last_time_clicked = None
        super(Workspace, self).__init__(self.body, 'inactive', None) 
Example #7
Source File: set_snooze.py    From sclack with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, icon, title, id):
        markup = [' ', icon, ' ', title]
        self.id = id
        super(SetSnoozeWidgetItem, self).__init__(
            urwid.SelectableIcon(markup),
            None,
            {
                None: 'active_set_snooze_item',
                'quick_search_presence_active': 'quick_search_active_focus',
            }
        ) 
Example #8
Source File: mystations.py    From clay with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, station):
        self.station = station
        self.text = urwid.SelectableIcon(u' \u2708 {} '.format(
            self.station.name
        ), cursor_position=3)
        self.text.set_layout('left', 'clip', None)
        self.content = urwid.AttrWrap(
            self.text,
            'default',
            'selected'
        )
        super(MyStationListItem, self).__init__([self.content]) 
Example #9
Source File: myplaylists.py    From clay with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, playlist):
        self.playlist = playlist
        self.text = urwid.SelectableIcon(u' \u2630 {} ({})'.format(
            self.playlist.name,
            len(self.playlist.tracks)
        ), cursor_position=3)
        self.text.set_layout('left', 'clip', None)
        self.content = urwid.AttrWrap(
            self.text,
            'default',
            'selected'
        )
        super(MyPlaylistListItem, self).__init__([self.content]) 
Example #10
Source File: songlist.py    From clay with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, track):
        self.track = track
        self.rating = self.RATING_ICONS[track.rating]
        self.explicit = self.EXPLICIT_ICONS[track.explicit_rating]
        self.index = 0
        self.state = SongListItem.STATE_IDLE
        self.line1_left = urwid.SelectableIcon('', cursor_position=1000)
        self.line1_left.set_layout('left', 'clip', None)
        self.line1_right = urwid.Text('x')
        self.line1 = urwid.Columns([
            self.line1_left,
            ('pack', self.line1_right),
            ('pack', urwid.Text(' '))
        ])
        self.line2 = urwid.Text('', wrap='clip')

        self.line1_wrap = urwid.AttrWrap(self.line1, 'line1')
        self.line2_wrap = urwid.AttrWrap(self.line2, 'line2')

        self.content = urwid.Pile([
            self.line1_wrap,
            self.line2_wrap,
            urwid.Text('')
        ])

        self.is_focused = False

        super(SongListItem, self).__init__([
            self.content
        ])
        self.update_text() 
Example #11
Source File: music_objects.py    From tuijam with MIT License 5 votes vote down vote up
def to_ui(*txts, weights=()):
        first, *rest = [
            (weight, str(txt))
            for weight, txt in zip_longest(weights, txts, fillvalue=1)
        ]
        items = [("weight", first[0], urwid.SelectableIcon(first[1], 0))]

        for weight, line in rest:
            items.append(("weight", weight, urwid.Text(line)))

        line = urwid.Columns(items)
        line = urwid.AttrMap(line, "search normal", "search select")

        return line 
Example #12
Source File: __main__.py    From hangups with MIT License 5 votes vote down vote up
def __init__(self, timestamp, text, datetimefmt, user=None,
                 show_date=False, watermark_users=None):
        # Save the timestamp as an attribute for sorting.
        self.timestamp = timestamp
        text = [
            ('msg_date', self._get_date_str(timestamp, datetimefmt,
                                            show_date=show_date) + ' '),
            ('msg_text_self' if user is not None and user.is_self
             else 'msg_text', text)
        ]
        if user is not None:
            text.insert(1, ('msg_self' if user.is_self else 'msg_sender',
                            user.first_name + ': '))

        if watermark_users is not None and bool(watermark_users):
            sorted_users = sorted([x.first_name for x in watermark_users])
            watermark = "\n[ Seen by {}. ]".format(', '.join(sorted_users))
            text.append(('msg_watermark', watermark))

        self._widget = urwid.SelectableIcon(text, cursor_position=0)
        super().__init__(urwid.AttrMap(
            self._widget, '', {
                # If the widget is focused, map every other display attribute
                # to 'msg_selected' so the entire message is highlighted.
                None: 'msg_selected',
                'msg_date': 'msg_selected',
                'msg_text_self': 'msg_selected',
                'msg_text': 'msg_selected',
                'msg_self': 'msg_selected',
                'msg_sender': 'msg_selected',
                'msg_watermark': 'msg_selected',
            }
        ))