本文整理汇总了Python中foobnix.helpers.image.ImageBase.get_allocation方法的典型用法代码示例。如果您正苦于以下问题:Python ImageBase.get_allocation方法的具体用法?Python ImageBase.get_allocation怎么用?Python ImageBase.get_allocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类foobnix.helpers.image.ImageBase
的用法示例。
在下文中一共展示了ImageBase.get_allocation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CoverLyricsPanel
# 需要导入模块: from foobnix.helpers.image import ImageBase [as 别名]
# 或者: from foobnix.helpers.image.ImageBase import get_allocation [as 别名]
class CoverLyricsPanel(Gtk.Frame):
def __init__(self, controls):
Gtk.Frame.__init__(self)
vbox = Gtk.VBox(False, 5)
self.controls = controls
self.set_size_request(100, 200)
self.album_title = Gtk.Label(_("Album title"))
image_size = FC().main_window_size[2] - (FC().hpaned_right + 16)
self.image = ImageBase(ICON_BLANK_DISK, size=image_size)
image_frame = Gtk.Frame()
image_frame.add(self.image)
image_frame.set_label_widget(Gtk.Label(_("Cover:")))
vbox.pack_start(image_frame, False, False, 0)
self.lyrics = TextArea()
self.lyrics.connect("size-allocate", self.adapt_image)
lyrics_frame = Gtk.Frame()
lyrics_frame.add(self.lyrics)
lyrics_frame.set_label_widget(Gtk.Label(_("Lyric:")))
vbox.pack_start(lyrics_frame, True, True, 0)
self.add(vbox)
self.set_label_widget(self.album_title)
self.show_all()
def get_pixbuf(self):
return self.controls.perspectives.get_perspective('info').get_widget().image.pixbuf
def set_cover(self):
pixbuf = self.get_pixbuf()
self.image.size = FC().info_panel_image_size
self.image.set_from_pixbuf(pixbuf)
def adapt_image(self, *a):
dif = self.lyrics.get_allocation().width - self.image.get_allocation().width
if self.lyrics.get_property("visible") and dif < 2:
self.image.size = self.lyrics.get_allocation().width - 20
self.image.set_from_pixbuf(self.controls.coverlyrics.get_pixbuf())