def applet_set_full_icon(self, pixbuf): size = self.get_size() icon = IconFactory().load_icon(self.config['icon_full'], size) if self.config['composite_icon'] \ and isinstance(icon, gtk.gdk.Pixbuf) \ and isinstance(pixbuf, gtk.gdk.Pixbuf): pixbuf = IconFactory().scale_to_bounded(pixbuf, 0.9 * size) cx = (size-pixbuf.get_width())/2 cy = (size-pixbuf.get_height())/2 trans = gdk.Pixbuf( pixbuf.get_colorspace(), True, pixbuf.get_bits_per_sample(), size, size) trans.fill(0x00000000) pixbuf.composite( trans, cx, cy, pixbuf.get_width(), pixbuf.get_height(), cx, cy, 1, 1, gtk.gdk.INTERP_BILINEAR, 255) icon.composite( trans, 0,0, size, size, 0, 0, 1, 1, gtk.gdk.INTERP_BILINEAR, 255) icon = trans if icon: self.set_icon_pixbuf(icon)
def get_rgb_rawdata(pixmap, x, y, width, height, logger=None): """ Extracts pixels from the given pixmap """ start = monotonic_time() pixmap_w, pixmap_h = pixmap.get_size() # Just in case we somehow end up with damage larger than the pixmap, # we don't want to start requesting random chunks of memory (this # could happen if a window is resized but we don't throw away our # existing damage map): assert x >= 0 assert y >= 0 if x + width > pixmap_w: width = pixmap_w - x if y + height > pixmap_h: height = pixmap_h - y if width <= 0 or height <= 0: return None colormap = pixmap.get_colormap() if not colormap: log.error("get_rgb_rawdata(..) no colormap for RGB pixbuf %sx%s", width, height) return None pixbuf = gdk.Pixbuf(gdk.COLORSPACE_RGB, False, 8, width, height) pixbuf.get_from_drawable(pixmap, colormap, x, y, 0, 0, width, height) if logger: logger( "get_rgb_rawdata(..) pixbuf.get_from_drawable took %s ms, visual depth=%s", int(1000 * (monotonic_time() - start)), colormap.get_visual().depth) raw_data = pixbuf.get_pixels() rowstride = pixbuf.get_rowstride() return (x, y, width, height, raw_data, "RGB", 24, rowstride, 3)
def take_screenshot(win=None): if win is None: win = gdk.get_default_root_window() sz = win.get_size() pb = gdk.Pixbuf(gdk.COLORSPACE_RGB, False, 8, sz[0], sz[1]) pb = pb.get_from_drawable(win, win.get_colormap(), 0, 0, 0, 0, sz[0], sz[1]) return pb.get_pixels_array()
def __init__(self, x, y, w, h, alpha=False, data=None): assert w > 0 and h > 0 # We create and use a pixbuf enlarged to the tile boundaries internally. # Variables ex, ey, ew, eh and epixbuf store the enlarged version. self.x, self.y, self.w, self.h = x, y, w, h #print x, y, w, h tx = self.tx = x / N ty = self.ty = y / N self.ex = tx * N self.ey = ty * N tw = (x + w - 1) / N - tx + 1 th = (y + h - 1) / N - ty + 1 self.ew = tw * N self.eh = th * N #print 'b:', self.ex, self.ey, self.ew, self.eh # OPTIMIZE: remove assertions here? assert self.ew >= w and self.eh >= h assert self.ex <= x and self.ey <= y self.epixbuf = gdk.Pixbuf(gdk.COLORSPACE_RGB, alpha, 8, self.ew, self.eh) dx = x - self.ex dy = y - self.ey self.pixbuf = self.epixbuf.subpixbuf(dx, dy, w, h) assert self.ew <= w + 2 * N - 2 assert self.eh <= h + 2 * N - 2 if not alpha: #self.epixbuf.fill(0xff44ff44) # to detect uninitialized memory pass # speeds up scrolling slightly else: self.epixbuf.fill(0x00000000) # keep undefined regions transparent arr = helpers.gdkpixbuf2numpy(self.epixbuf) discard_transparent = False if data is not None: dst = arr[dy:dy + h, dx:dx + w, :] if data.shape[2] == 3: # no alpha dst[:, :, 0:3] = data dst[:, :, 3] = 255 else: dst[:, :, :] = data # this surface will be used read-only discard_transparent = True self.tile_memory_dict = {} for ty in range(th): for tx in range(tw): buf = arr[ty * N:(ty + 1) * N, tx * N:(tx + 1) * N, :] if discard_transparent and not buf[:, :, 3].any(): continue self.tile_memory_dict[(self.tx + tx, self.ty + ty)] = buf
def f(t,width,height): time.sleep(t) w = g.get_default_root_window() sz = (width,height) pb = g.Pixbuf(g.COLORSPACE_RGB, False, 8,*sz) cm = w.get_colormap() pb = pb.get_from_drawable(w,cm,58,141,0,0,*sz) im = Image(pb.get_pixels_array()) #creates simplecv image from pixbuf return im
def _grab_screenshot_gtk_py2(): window = gdk.get_default_root_window() if not window: raise RuntimeError('Taking screenshot failed.') width, height = window.get_size() pb = gdk.Pixbuf(gdk.COLORSPACE_RGB, False, 8, width, height) pb = pb.get_from_drawable(window, window.get_colormap(), 0, 0, 0, 0, width, height) if not pb: raise RuntimeError('Taking screenshot failed.') return pb
def draw(self, graph, icon, bgCol, fgCol, max=100): bg = gdk.Pixbuf(gdk.COLORSPACE_RGB, True, 8, w, h) bg.fill(bgCol) pixbuf = gdk.Pixbuf(gdk.COLORSPACE_RGB, True, 8, w, h) pixbuf.fill(0x00000000) pixmap = pixbuf.render_pixmap_and_mask(alpha_threshold=127)[0] cr = pixmap.cairo_create() cr.set_source_rgba(fgCol[0], fgCol[1], fgCol[2], fgCol[3]) for x in range(w): y = int(round(graph[x] / max * h)) if y: cr.move_to(x, h) cr.line_to(x, h - y) cr.stroke() pixbuf.get_from_drawable(pixmap, pixmap.get_colormap(), 0, 0, 0, 0, w, h) pixbuf = pixbuf.add_alpha(True, 0x00, 0x00, 0x00) pixbuf.composite(bg, 0, 0, w, h, 0, 0, 1, 1, gtk.gdk.INTERP_NEAREST, 255) icon.set_from_pixbuf(bg)
def copyDuplicateToCanvas(self, canvas): x, y, ww, hh = canvas.get_allocation() pixbuf = gdk.Pixbuf(colorspace=gdk.COLORSPACE_RGB, has_alpha=True, bits_per_sample=8, width=ww, height=hh) pixbuf.get_from_drawable(self.duplicate, canvas.window.get_colormap(), 0, 0, 0, 0, ww, hh) pixbuf = pixbuf.add_alpha(True, *'\0\0\0') canvas.root().add("GnomeCanvasPixbuf", pixbuf=pixbuf, x=0, y=0)
def _gtk_screenshot(self, path): window = gdk.get_default_root_window() if not window: raise RuntimeError('Taking screenshot failed') width, height = window.get_size() pb = gdk.Pixbuf(gdk.COLORSPACE_RGB, False, 8, width, height) pb = pb.get_from_drawable(window, window.get_colormap(), 0, 0, 0, 0, width, height) if not pb: raise RuntimeError('Taking screenshot failed') pb.save(path, 'jpeg')
def pixbuf_thumbnail(src, w, h, alpha=False): """ Creates a centered thumbnail of a gdk.pixbuf. """ src2 = scale_proportionally(src, w, h) w2, h2 = src2.get_width(), src2.get_height() dst = gdk.Pixbuf(gdk.COLORSPACE_RGB, alpha, 8, w, h) if alpha: dst.fill(0xffffff00) # transparent background else: dst.fill(0xffffffff) # white background src2.copy_area(0, 0, w2, h2, dst, (w-w2)/2, (h-h2)/2) return dst
def gtk_scale_pixbuf(src_pixbuf, sx, sy, sw, sh, dw, dh): """Return a new pixbuf containing the specified part of the given pixbuf scaled to the specified size.""" dst_pixbuf = gdk.Pixbuf( src_pixbuf.get_colorspace(), src_pixbuf.get_has_alpha(), src_pixbuf.get_bits_per_sample(), dw, dh) xscale = float(dw) / sw yscale = float(dh) / sh xoffset = - xscale * sx yoffset = - yscale * sy src_pixbuf.scale(dst_pixbuf, 0, 0, dw, dh, xoffset, yoffset, xscale, yscale, gdk.INTERP_BILINEAR) return dst_pixbuf
def _record_gtk_py2(path, fps, stop): window = gdk.get_default_root_window() fourcc = cv2.VideoWriter_fourcc(*'VP08') width, height = window.get_size() with suppress_stderr(): vid = cv2.VideoWriter('%s' % path, fourcc, fps, (width, height)) while not stop.isSet(): pb = gdk.Pixbuf(gdk.COLORSPACE_RGB, False, 8, width, height) pb = pb.get_from_drawable(window, window.get_colormap(), 0, 0, 0, 0, width, height) numpy_array = pb.get_pixels_array() frame = cv2.cvtColor(numpy_array, cv2.COLOR_RGB2BGR) vid.write(frame) vid.release() cv2.destroyAllWindows()
def initialize_text_tray(self): self.traySize = 19 self.trayPixbuf = gdk.Pixbuf(gdk.COLORSPACE_RGB, True, 8, self.traySize, self.traySize) self.trayPixbuf.fill(0x00000000) self.pixmap = self.trayPixbuf.render_pixmap_and_mask(alpha_threshold=127)[0] self.cr = self.pixmap.cairo_create() self.cr.select_font_face("Georgia", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_BOLD) self.cr.set_operator(cairo.OPERATOR_SOURCE) self.color_seen = (1, 1, 1, 1) self.cr.set_source_rgba(*self.color_seen) default_font_size = 20 self.cr.set_font_size(default_font_size) self.trayPixbuf.get_from_drawable(self.pixmap, self.pixmap.get_colormap(), 0, 0, 0, 0, self.traySize, self.traySize) self.trayPixbuf = self.trayPixbuf.add_alpha(True, 0x00, 0x00, 0x00)
def draw_text(self, text): pixbuf = gdk.Pixbuf(gdk.COLORSPACE_RGB, True, 8, ICON_SIZE, ICON_SIZE) pixbuf.fill(0x00000000) pixmap = pixbuf.render_pixmap_and_mask(alpha_threshold=127)[0] cr = pixmap.cairo_create() cr.select_font_face(FONT_FACE, cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_BOLD) cr.set_source_rgba(0.9, 0.9, 0.9, 1) cr.set_font_size(FONT_SIZE) cr.move_to(0, Y_OFFSET) cr.show_text(text) pixbuf.get_from_drawable(pixmap, pixmap.get_colormap(), 0, 0, 0, 0, ICON_SIZE, ICON_SIZE) pixbuf = pixbuf.add_alpha(True, 0x00, 0x00, 0x00) return pixbuf
def _grab_screenshot_gtk_py2(monitor): window = gdk.get_default_root_window() if not window: raise RuntimeError('Taking screenshot failed.') width, height = window.get_size() pb = gdk.Pixbuf(gdk.COLORSPACE_RGB, False, 8, width, height) if not pb: raise RuntimeError('Taking screenshot failed.') if monitor == 0: pb = pb.get_from_drawable(window, window.get_colormap(), 0, 0, 0, 0, width, height) else: monitors = _get_monitors(window) pb = pb.get_from_drawable(window, window.get_colormap(), monitors[monitor - 1].x, monitors[monitor - 1].y, 0, 0, monitors[monitor - 1].width, monitors[monitor - 1].height) return pb
def do_realize(self): """ Realize the widget """ self.set_flags(self.flags() | gtk.REALIZED) self.window = gdk.Window(self.get_parent_window(), width=self.allocation.width, height=self.allocation.height, window_type=gdk.WINDOW_CHILD, wclass=gdk.INPUT_OUTPUT, event_mask=self.get_events() | gdk.EXPOSURE_MASK | gdk.BUTTON1_MOTION_MASK | gdk.BUTTON_PRESS_MASK | gdk.BUTTON_RELEASE_MASK | gdk.POINTER_MOTION_MASK | gdk.POINTER_MOTION_HINT_MASK) self.window.set_user_data(self) self.style.attach(self.window) self.style.set_background(self.window, gtk.STATE_NORMAL) self.window.move_resize(*self.allocation) self.gc = self.window.new_gc() self.color_changed(self.color) pbuf = gdk.pixbuf_new_from_file( os.path.join(self.icon_path, "dropper.png")) if pbuf: self.cursor = gdk.Cursor(self.window.get_display(), pbuf, 8, 21) self.set_tooltip_text( 'Click and drag:\n Left: drag-n-drop color\n\nLeft click: add to palette' ) self.connect("motion-notify-event", self.cb_motion_notify) self.connect("button-press-event", self.cb_button_press) self.connect("button-release-event", self.cb_button_release) self.connect("drag-begin", self.cb_drag_begin) self.dnd_helper = ColorDndHelper(self, self.cb_drag_set_color, self.cb_drag_get_color, gtk.gdk.BUTTON1_MASK) self.raw_width = 1 self.raw_height = 1 self.raw_pixbuf = gdk.Pixbuf(gdk.COLORSPACE_RGB, False, 8, self.raw_width, self.raw_height)
def acquire(self): """Acquire screen image.""" self.pixbuf = gdk.Pixbuf( gdk.COLORSPACE_RGB, False, 8, self.x_max, self.y_max) self.pixbuf = self.pixbuf.get_from_drawable( self.gdkroot, self.gdkroot.get_colormap(), int(self.x_ctr), int(self.y_ctr), 0, 0, int(self.x_max), int(self.y_max))
def get_screenData(): while 1: # get screenshot data if major_version == 2: pb = Gdk.Pixbuf(Gdk.COLORSPACE_RGB, False, 8, sz[0], sz[1]) pb = pb.get_from_drawable(w, w.get_colormap(), 0, 0, 0, 0, sz[0], sz[1]) elif major_version == 3: pb = Gdk.pixbuf_get_from_window(w, 0, 0, sz[0], sz[1]) # save screenshot if pb != None: if major_version == 2: pb.save("./scr.png", "png") elif major_version == 3: pb.savev("./scr.png", "png", [], []) # delay 1 sec time.sleep(0.9)
def _get_desk(self): u''' Инициализирует переменную self.desk ''' w = gd.get_default_root_window() sz = w.get_size() pb = gd.Pixbuf(gd.COLORSPACE_RGB,False,8,sz[0],sz[1]) pb = pb.get_from_drawable(w,w.get_colormap(),0,0,0,0,sz[0],sz[1]) img_rgb = pb.get_pixels_array() # subprocess.call('scrot %s' %self.desk_file, shell=True) # img_rgb = cv2.imread(self.desk_file) # img_rgb = cv2.imread('1.png') img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY) self.desk = img_gray # Вырежим нашу доску self.desk_x, self.desk_y = self._get_desk_coord() img = img_gray[self.desk_y: self.desk_y + 8*self.h, self.desk_x: self.desk_x + 8*self.w] self.desk = img
def capture(self, scale_x=None, scale_y=None, quality=75, raw=False): """Captures a screenshot and returns in for width, height, data""" screenshot = gdk.Pixbuf(gdk.COLORSPACE_RGB, False, 8, self.width, self.height) screenshot.get_from_drawable(gdk.get_default_root_window(), gdk.colormap_get_system(), 0, 0, 0, 0, self.width, self.height) if not scale_x: scale_x = self.width if not scale_y: scale_y = self.height if self.width != scale_x or self.height != scale_y: screenshot = screenshot.scale_simple(scale_x, scale_y, gdk.INTERP_BILINEAR) if raw: return scale_x, scale_y, screenshot else: image=[] screenshot.save_to_callback(lambda buf, image: image.append(buf), "jpeg", {"quality": str(quality)}, image) return scale_x, scale_y, "".join(image)
def compare_png(self, actual, x, y, w, h): backing = self.window._backing._backing from gtk import gdk pixbuf = gdk.Pixbuf(gdk.COLORSPACE_RGB, True, 8, w, h) try: pixbuf.get_from_drawable(backing, backing.get_colormap(), 0, 0, 0, 0, w, h) except Exception as e: print("cannot get drawable from %s: %s" % (backing, e)) return from PIL import Image result = Image.frombytes("RGBA", (w, h), pixbuf.get_pixels(), "raw", "RGBA", pixbuf.get_rowstride()).convert("RGB") expected = PIL_open(actual) from PIL import ImageChops diff = ImageChops.difference(result, expected) #print("compare_png: %s -> %s -> %s" % (backing, pixbuf, result)) output = StringIO() diff.save(output, format="png") contents = output.getvalue() output.close() self.paint_png(contents, x, y, w, h)
def background(self): """Paint window when mouse moves window.""" self.cairo.set_operator(cairo.OPERATOR_SOURCE) self.x_ctr = min( max(self.x_ptr - self.x_max/2, 0),self.x_top-self.x_max-1) self.y_ctr = min( max(self.y_ptr - self.y_max/2, 0),self.y_top-self.y_max-1) pixbuf = gdk.Pixbuf( gdk.COLORSPACE_RGB, False, 8, self.x_max, self.y_max) pixbuf = pixbuf.get_from_drawable( self.gdkroot, self.gdkroot.get_colormap(), self.x_ctr, self.y_ctr, 0, 0, self.x_max, self.y_max) source = pixbuf.scale_simple( int(self.x_max * self.zooming), int(self.y_max * self.zooming), gdk.INTERP_NEAREST) pixarray = source.pixel_array minp, maxp = min(pixarray), max(pixarray) print minp, maxp #TODO transform source into target target = source self.cairo.set_source_pixbuf(target, 0, 0) self.cairo.paint()
def __init__(self, file=None, pixbuf=None, width=0, height=0, fill=None, outline=None): if file: self.pixbuf = gdk.pixbuf_new_from_file(file) elif pixbuf: self.pixbuf = pixbuf else: self.pixbuf = gdk.Pixbuf(gdk.COLORSPACE_RGB, True, 8, width, height) if fill: c = gdk.color_parse(fill) c = '%02x%02x%02xffL' % (c.red, c.green, c.blue) self.pixbuf.fill(int(c, 16)) else: self.pixbuf.fill(0) if outline: # FIXME pass
def scale(self): """ Scale grabbed image data by zoom factor The image data in raw_pixbuf is scaled by the zoom factor and the scaled image data is stored in pixbuf. This queues the widget to be redrawn. """ if self.has_data == False: return if (self.pixbuf_height != self.raw_height * self.zoom or self.pixbuf_width != self.raw_width * self.zoom): self.pixbuf_width = int(self.raw_width * self.zoom) self.pixbuf_height = int(self.raw_height * self.zoom) self.pixbuf = gdk.Pixbuf(gdk.COLORSPACE_RGB, False, 8, self.pixbuf_width, self.pixbuf_height) # scale up by zoom factor self.raw_pixbuf.scale(self.pixbuf, 0, 0, self.pixbuf_width, self.pixbuf_height, 0, 0, self.zoom, self.zoom, gdk.INTERP_NEAREST) self.queue_draw()
def grab_immediate(self, x, y, w, h): """ Copy pixels from the region specified by (x,y,w,h) into internal pixbuf The coordinates are relative to the screen in units of pixels. The grabbed image data is stored in raw_pixbuf. This involves copying image data from the server to the client and thus is not the quickest of operations. Do not call more often than necessary. """ self.screen_rect = gdk.Rectangle(x, y, w, h) self.pan_x = 0 self.pan_y = 0 # if we're grabbing a different size, create new pixbuf of correct size if (self.screen_rect.width != self.raw_width or self.screen_rect.height != self.raw_height): self.raw_width = self.screen_rect.width self.raw_height = self.screen_rect.height self.raw_pixbuf = gdk.Pixbuf(gdk.COLORSPACE_RGB, False, 8, self.raw_width, self.raw_height) # grab raw screen data self.raw_pixbuf.get_from_drawable(gdk.get_default_root_window(), gdk.colormap_get_system(), self.screen_rect.x, self.screen_rect.y, 0, 0, self.screen_rect.width, self.screen_rect.height) self.emit('location-changed') self.has_data = True self.scale()
def _snap_linux(self): from gtk import gdk window = gdk.get_default_root_window() size = window.get_size() print("The size of the window is %d x %d" % size) pb = gdk.Pixbuf(gdk.COLORSPACE_RGB, False, 8, size[0], size[1]) pb = pb.get_from_drawable(window, window.get_colormap(), 0, 0, 0, 0, size[0], size[1]) if not pb: raise Exception("Unable to get the screenshot.") buffer = StringIO() pb.save('screenshot.png', "png") buffer.write(open('screenshot.png', 'rb').read()) print("Screenshot saved") buffer.seek(0) return buffer
return input pb, = input pixmap, mask = pb.render_pixmap_and_mask() if mask is not None: gc = gdk.gc_new(self.window.window) gc.set_clip_mask(mask) return (pixmap, gc, mask) else: return (pixmap, self.gc, None) def getopticon(self, input, (x, y, w, h), ignored_alpha=255): if len(input) == 3: return None pb, = input scale = self.scale newpb = gdk.Pixbuf("rgb", 1, 8, w, h) newpb.fill(0) pb.copy_area(x, y, w, h, newpb, 0, 0) newpb = newpb.scale_simple(int(w*scale), int(h*scale), gdk.INTERP_HYPER) if newpb is None: return None, None, None else: return self.renderpixbuf((newpb,)) def getppm(self, (x, y, w, h), int=int, ceil=math.ceil): scale = self.scale if isinstance(scale, int): x *= scale y *= scale w *= scale
import gtk.gdk as gdk import time w = gdk.screen_width() h = gdk.screen_height() sg = gdk.Pixbuf(gdk.COLORSPACE_RGB, False, 8, w, h) start = time.clock() pb = sg.get_from_drawable(gdk.get_default_root_window(), gdk.colormap_get_system(), 0, 0, 0, 0, w, h) print(time.clock() - start)
def do_realize(self): """ Realize the widget This creates the server resources (gdk window, cursors, pixbufs, etc) and sets up drag and drop handlers """ self.set_flags(self.flags() | gtk.REALIZED) self.window = gdk.Window(self.get_parent_window(), width=self.allocation.width, height=self.allocation.height, window_type=gdk.WINDOW_CHILD, wclass=gdk.INPUT_OUTPUT, event_mask=self.get_events() | gdk.EXPOSURE_MASK | gdk.BUTTON1_MOTION_MASK | gdk.BUTTON_PRESS_MASK | gdk.BUTTON_RELEASE_MASK | gdk.POINTER_MOTION_MASK | gdk.POINTER_MOTION_HINT_MASK) try: pbuf = gdk.pixbuf_new_from_file( os.path.join(self.icon_path, "magnify.png")) self.cursors['magnify'] = gdk.Cursor(self.window.get_display(), pbuf, 6, 6) except glib.GError: self.cursors['magnify'] = None try: pbuf = gdk.pixbuf_new_from_file( os.path.join(self.icon_path, "measure.png")) self.cursors['measure'] = gdk.Cursor(self.window.get_display(), pbuf, 6, 6) except glib.GError: self.cursors['measure'] = None #self.set_cursor('magnify') self.pixbuf_width = int(self.allocation.width) self.pixbuf_height = int(self.allocation.height) self.raw_width = int(self.allocation.width / self.zoom) self.raw_height = int(self.allocation.height / self.zoom) self.window.set_user_data(self) self.style.attach(self.window) self.style.set_background(self.window, gtk.STATE_NORMAL) self.window.move_resize(*self.allocation) self.gc = self.style.fg_gc[gtk.STATE_NORMAL] self.measure_gc = gdk.GC(self.window) self.measure_gc.set_foreground( self.measure_gc.get_colormap().alloc_color("#fff")) self.measure_gc.set_background( self.measure_gc.get_colormap().alloc_color("#000")) self.measure_gc.set_dashes(0, (4, 4)) self.measure_gc.set_line_attributes(1, gdk.LINE_DOUBLE_DASH, gdk.CAP_BUTT, gdk.JOIN_MITER) self.grid_gc = gdk.GC(self.window) self.grid_gc.set_foreground( self.measure_gc.get_colormap().alloc_color("#777")) self.connect("motion-notify-event", self.cb_motion_notify) self.connect("button-press-event", self.cb_button_press) self.connect("button-release-event", self.cb_button_release) self.connect("scroll-event", self.cb_scroll) self.pixbuf = gdk.Pixbuf(gdk.COLORSPACE_RGB, False, 8, self.pixbuf_width, self.pixbuf_height) self.raw_pixbuf = gdk.Pixbuf(gdk.COLORSPACE_RGB, False, 8, self.raw_width, self.raw_height) target_list = gtk.target_list_add_image_targets( None, self.TARGET_TYPE_IMAGE, True) self.drag_source_set(gtk.gdk.BUTTON1_MASK, target_list, gtk.gdk.ACTION_COPY) self.connect("drag-data-get", self.cb_drag_data_get)