Quote:
Originally Posted by eschwartz
Doitsu -- for python2+3 you can use:
Code:
from gi.repository import Gtk, Gdk
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
image = cb.wait_for_text()
|
Thanks for the suggestion. I'd actually experimented with the following similar code:
Code:
import tempfile
from gi.repository import Gtk, Gdk
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
img = clipboard.wait_for_image()
if img:
temp_file = tempfile.NamedTemporaryFile().name
img.save(temp_file, 'jpeg')
but I got a weird error message for
img.save() that I couldn't resolve:
Code:
AttributeError: 'Pixbuf' object has no attribute 'save'
Error: 'Pixbuf' object has no attribute 'save'
even though
img is a Gtk 3.0
gi.repository.GdkPixbuf.Pixbuf object, which definitely should have a
save attribute.