本文整理匯總了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())