E
exhuma.twn
As many might know, windows allows to copy an image into the clipboard
by pressing the "Print Screen" button on the keyboard. Is it possible
to paste such an image from the clipboard into a "Text" widget in
Tkinter? Here is my first attempt with just trying to print out the
image data:
-----------------
def pasteImg(tgt):
global clipboardEnabled
if not clipboardEnabled: return
win32clipboard.OpenClipboard(0)
print win32clipboard.GetClipboardData()
win32clipboard.CloseClipboard()
-----------------
This works fine with selecting text, but comes up with the following
error when trying to paste an image:
-----------------
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__
return self.func(*args)
File "X:\development\testing\tkwiki\tkwiki.py", line 52, in <lambda>
Button( root, command=lambda: pasteImg(txt) ).pack()
File "X:\development\testing\tkwiki\tkwiki.py", line 38, in pasteImg
print win32clipboard.GetClipboardData()
TypeError: Specified clipboard format is not available
by pressing the "Print Screen" button on the keyboard. Is it possible
to paste such an image from the clipboard into a "Text" widget in
Tkinter? Here is my first attempt with just trying to print out the
image data:
-----------------
def pasteImg(tgt):
global clipboardEnabled
if not clipboardEnabled: return
win32clipboard.OpenClipboard(0)
print win32clipboard.GetClipboardData()
win32clipboard.CloseClipboard()
-----------------
This works fine with selecting text, but comes up with the following
error when trying to paste an image:
-----------------
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__
return self.func(*args)
File "X:\development\testing\tkwiki\tkwiki.py", line 52, in <lambda>
Button( root, command=lambda: pasteImg(txt) ).pack()
File "X:\development\testing\tkwiki\tkwiki.py", line 38, in pasteImg
print win32clipboard.GetClipboardData()
TypeError: Specified clipboard format is not available