View Single Post
Old 11-13-2015, 02:03 PM   #7
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,737
Karma: 24031401
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by eschwartz View Post
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.
Doitsu is offline   Reply With Quote