def __init__(self, parent, img, title): Gtk.ScrolledWindow.__init__(self) pixbuf = pil_to_pixbuf(img) self.img_widget = Gtk.Image.new_from_pixbuf(pixbuf) self.img_widget.set_hexpand(True) # Fill available horizontal space self.img_widget.set_vexpand(True) # Fill available vertical space self.event_box = Gtk.EventBox() self.event_box.add(self.img_widget) self.event_box.set_events(Gdk.EventMask.BUTTON1_MOTION_MASK) self.event_box.connect('button-press-event', parent.editor.press_task) self.event_box.connect('motion-notify-event', parent.editor.move_task) self.event_box.connect('button-release-event', parent.editor.release_task) self.add(self.event_box) self.tab_label = TabLabel(title, img) self.tab_label.connect('close-clicked', parent.on_close_tab_clicked, self)
def set_icon(self, img): icon = img.copy() icon.thumbnail((24, 24)) pixbuf = pil_to_pixbuf(icon) self.icon_widget.set_from_pixbuf(pixbuf)
def update_image(self, new_img): pixbuf = pil_to_pixbuf(new_img) self.img_widget.set_from_pixbuf(pixbuf)