本文整理汇总了Python中miro.frontends.widgets.imagepool.get_surface函数的典型用法代码示例。如果您正苦于以下问题:Python get_surface函数的具体用法?Python get_surface怎么用?Python get_surface使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_surface函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _set_from_info
def _set_from_info(self, guide_info):
if guide_info is None:
return
# XXX This code is a bit ugly, because we want to use pretty defaults for
# the Miro Guide, but still allow themes to override
if guide_info.default and guide_info.url in _guide_url_to_title_map:
self.name = _guide_url_to_title_map[guide_info.url]
else:
self.name = guide_info.name
if guide_info.default and guide_info.url in _guide_url_to_icon_map:
# one of our default guides
self.icon_name = _guide_url_to_icon_map[guide_info.url]
self.icon = widgetutil.make_surface(self.icon_name)
elif guide_info.faviconIsDefault:
# theme guide that should use default favicon
self.icon = widgetutil.make_surface(self.icon_name)
else:
# theme guide with a favicon
surface = imagepool.get_surface(guide_info.favicon)
if surface.width != 23 or surface.height != 23:
self.icon = imagepool.get_surface(guide_info.favicon,
size=(23, 23))
else:
self.icon = surface
示例2: init_info
def init_info(self, info):
info.type = u'sharing'
info.unwatched = info.available = 0
active = None
if info.is_folder and info.playlist_id is None:
thumb_path = resources.path('images/sharing.png')
# Checking the name instead of a supposedly unique id is ok for now
# because
elif info.playlist_id == u'video':
thumb_path = resources.path('images/icon-video.png')
active = resources.path('images/icon-video_active.png')
info.name = _('Video')
elif info.playlist_id == u'audio':
thumb_path = resources.path('images/icon-audio.png')
active = resources.path('images/icon-audio_active.png')
info.name = _('Music')
elif info.playlist_id == u'playlist':
thumb_path = resources.path('images/icon-playlist.png')
active = resources.path('images/icon-playlist_active.png')
info.name = _('Playlists')
elif info.playlist_id == u'podcast':
thumb_path = resources.path('images/icon-podcast.png')
active = resources.path('images/icon-podcast_active.png')
info.name = _('Podcasts')
else:
if info.podcast:
thumb_path = resources.path('images/icon-podcast-small.png')
active = resources.path('images/icon-podcast-small_active.png')
else:
thumb_path = resources.path('images/icon-playlist-small.png')
active = resources.path('images/icon-playlist-small_active.png')
info.icon = imagepool.get_surface(thumb_path)
if active:
info.active_icon = imagepool.get_surface(active)
示例3: __init__
def __init__(self):
widgetset.DrawingArea.__init__(self)
self.video_icon = imagepool.get_surface(resources.path('images/mini-icon-video.png'))
self.audio_icon = imagepool.get_surface(resources.path('images/mini-icon-audio.png'))
self.reset()
app.playback_manager.connect('selecting-file', self.handle_selecting)
app.playback_manager.connect('will-play', self.handle_play)
app.playback_manager.connect('will-stop', self.handle_stop)
示例4: __init__
def __init__(self):
ListViewRenderer.__init__(self)
self.button = {}
for button in self.BUTTONS:
path = resources.path('images/%s-button.png' % button)
self.button[button] = imagepool.get_surface(path)
path = resources.path('images/download-arrow.png')
self.download_icon = imagepool.get_surface(path)
示例5: __init__
def __init__(self):
widgetset.DragableCustomButton.__init__(self)
self.value = False
self.background = imagepool.get_surface(
resources.path('images/connect-toggle-bg.png'))
self.on = imagepool.get_surface(
resources.path('images/connect-toggle-on.png'))
self.off = imagepool.get_surface(
resources.path('images/connect-toggle-off.png'))
示例6: init_playlist_info
def init_playlist_info(self, info):
info.type = u'sharing-playlist'
if info.podcast:
thumb_path = resources.path('images/icon-podcast-small.png')
active = resources.path('images/icon-podcast-small_active.png')
else:
thumb_path = resources.path('images/icon-playlist-small.png')
active = resources.path('images/icon-playlist-small_active.png')
info.icon = imagepool.get_surface(thumb_path)
info.active_icon = imagepool.get_surface(active)
示例7: init_info
def init_info(self, info):
if info.favicon:
thumb_path = info.favicon
else:
thumb_path = resources.path("images/icon-site.png")
surface = imagepool.get_surface(thumb_path)
if surface.width > 16 or surface.height > 16:
info.icon = imagepool.get_surface(thumb_path, size=(16, 16))
else:
info.icon = imagepool.get_surface(thumb_path)
info.unwatched = info.available = 0
示例8: __init__
def __init__(self):
widgetset.CustomButton.__init__(self)
self.set_can_focus(False)
self.video_icon = imagepool.get_surface(resources.path('images/mini-icon-video.png'))
self.audio_icon = imagepool.get_surface(resources.path('images/mini-icon-audio.png'))
self.reset()
app.playback_manager.connect('selecting-file', self.on_info_change)
app.playback_manager.connect('playing-info-changed',
self.on_info_change)
app.playback_manager.connect('will-play', self.handle_play)
app.playback_manager.connect('will-stop', self.handle_stop)
示例9: set_image
def set_image(self, image_name):
path = resources.path('images/%s.png' % image_name)
self.image = imagepool.get_surface(path)
pressed_path = resources.path('images/%s_active.png' % image_name)
self.pressed_image = imagepool.get_surface(pressed_path)
disabled_path = resources.path('images/%s_disabled.png' % image_name)
if os.path.exists(disabled_path):
self.disabled_image = imagepool.get_surface(disabled_path)
else:
self.disabled_image = None
示例10: _draw_thumbnail
def _draw_thumbnail(self, context, x, y, width, height):
fraction = 1.0
if not self.data.state == 'running':
fraction = 0.4
icon = imagepool.get_surface(self.data.item_thumbnail, (width, height))
widgetutil.draw_rounded_icon(context, icon, x, y, width, height, fraction=fraction)
self.THUMB_OVERLAY.draw(context, x, y, width, height, fraction=fraction)
示例11: _fake_info
def _fake_info(self, info, typ, name):
new_data = {
'fake': True,
'tab_type': typ,
'id': u'%s-%s' % (info.id, typ),
'name': name,
'device_name': info.name,
'icon': imagepool.get_surface(
resources.path('images/icon-device-%s.png' % typ)),
'active_icon': imagepool.get_surface(
resources.path('images/icon-device-%s_active.png' % typ))
}
# hack to create a DeviceInfo without dealing with __init__
di = messages.DeviceInfo.__new__(messages.DeviceInfo)
di.__dict__ = info.__dict__.copy()
di.__dict__.update(new_data)
return di
示例12: render
def render(self, context, layout_manager, selected, hotspot, hover):
album_art = imagepool.get_surface(self.get_image_path(),
size=self.IMAGE_SIZE)
artist = self.get_artist()
album = self.get_album()
if self.group_info is None:
# we can't render if group_info isn't set
logging.warn("group_info is None in MultiRowAlbumRenderer")
return
if context.height == 0:
# not sure how this would happen, but we need to avoid
# divide-by-zero errors if it does
logging.warn("row height is 0 in MultiRowAlbumRenderer")
return
if not album:
# if we don't have an album name, then try to render the artist
# name. If not, just leave ourselves blank.
self.clear_cell(context)
if artist:
self.render_text(context, layout_manager, artist, True)
self.draw_bottom_line(context)
return
current_row, total_rows = self.group_info
# calculate how many rows we need to display the image
total_image_height = (album_art.height + self.IMAGE_MARGIN_TOP +
self.IMAGE_MARGIN_BOTTOM)
image_row_count = math.ceil(float(total_image_height) /
context.height)
# render the current cell
if total_rows < image_row_count:
# we don't have enough room to draw the image, just try to draw
# the text
image_row_count = 0
if current_row < image_row_count:
# draw image cells
self.render_image(context, album_art, current_row)
else:
# draw text and empty cells
self.clear_cell(context)
if current_row == image_row_count:
self.render_text(context, layout_manager, album, True)
elif current_row == image_row_count + 1:
self.render_text(context, layout_manager, artist, False)
# draw track number
self.render_track_number(context, layout_manager, current_row)
# render line below the album
if current_row == total_rows - 1:
self.draw_bottom_line(context)
示例13: make_album_art
def make_album_art(self, context):
"""Make an image to draw as album art.
Returns ImageSurface to draw or None if we don't have anything
"""
if self.get_total_rows() < 6:
# don't draw album art if we have less than 6 items in the group
return None
album_art_path = self.get_image_path()
if album_art_path is None:
return None
return imagepool.get_surface(album_art_path,
size=(self.album_art_size, self.album_art_size))
示例14: _fake_info
def _fake_info(self, info, name):
new_data = {
"fake": True,
"tab_type": name.lower(),
"id": "%s-%s" % (info.id, name.lower()),
"name": name,
"icon": imagepool.get_surface(resources.path("images/icon-%s.png" % name.lower())),
}
# hack to create a DeviceInfo without dealing with __init__
di = messages.DeviceInfo.__new__(messages.DeviceInfo)
di.__dict__ = info.__dict__.copy()
di.__dict__.update(new_data)
return di
示例15: _fake_info
def _fake_info(self, info, name):
new_data = {
'fake': True,
'tab_type': name.lower(),
'id': '%s-%s' % (info.id, name.lower()),
'name': name,
'icon': imagepool.get_surface(
resources.path('images/icon-%s.png' % name.lower()))
}
# hack to create a DeviceInfo without dealing with __init__
di = messages.DeviceInfo.__new__(messages.DeviceInfo)
di.__dict__ = info.__dict__.copy()
di.__dict__.update(new_data)
return di