當前位置: 首頁>>代碼示例>>Python>>正文


Python urwid.SelectableIcon方法代碼示例

本文整理匯總了Python中urwid.SelectableIcon方法的典型用法代碼示例。如果您正苦於以下問題:Python urwid.SelectableIcon方法的具體用法?Python urwid.SelectableIcon怎麽用?Python urwid.SelectableIcon使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在urwid的用法示例。


在下文中一共展示了urwid.SelectableIcon方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: cute_button

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import SelectableIcon [as 別名]
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 
開發者ID:bbj-dev,項目名稱:bbj,代碼行數:11,代碼來源:main.py

示例2: get_mark

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import SelectableIcon [as 別名]
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) 
開發者ID:what-studio,項目名稱:profiling,代碼行數:9,代碼來源:viewer.py

示例3: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import SelectableIcon [as 別名]
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'
            }
        ) 
開發者ID:haskellcamargo,項目名稱:sclack,代碼行數:14,代碼來源:quick_switcher.py

示例4: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import SelectableIcon [as 別名]
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') 
開發者ID:haskellcamargo,項目名稱:sclack,代碼行數:15,代碼來源:components.py

示例5: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import SelectableIcon [as 別名]
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',
            }
        ) 
開發者ID:haskellcamargo,項目名稱:sclack,代碼行數:13,代碼來源:set_snooze.py

示例6: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import SelectableIcon [as 別名]
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]) 
開發者ID:and3rson,項目名稱:clay,代碼行數:14,代碼來源:mystations.py

示例7: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import SelectableIcon [as 別名]
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]) 
開發者ID:and3rson,項目名稱:clay,代碼行數:15,代碼來源:myplaylists.py

示例8: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import SelectableIcon [as 別名]
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() 
開發者ID:and3rson,項目名稱:clay,代碼行數:33,代碼來源:songlist.py

示例9: to_ui

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import SelectableIcon [as 別名]
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 
開發者ID:cfangmeier,項目名稱:tuijam,代碼行數:16,代碼來源:music_objects.py

示例10: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import SelectableIcon [as 別名]
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',
            }
        )) 
開發者ID:tdryer,項目名稱:hangups,代碼行數:35,代碼來源:__main__.py


注:本文中的urwid.SelectableIcon方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。