本文整理汇总了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
示例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)
示例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'
}
)
示例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')
示例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',
}
)
示例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])
示例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])
示例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()
示例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
示例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',
}
))