Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy a picture from canvas to clipboard?

I have some Tkinter canvas and some picture of lines and text on it. Is there an easy way to copy it to a clipboard?

like image 679
akalenuk Avatar asked Jan 23 '23 21:01

akalenuk


1 Answers

You could use .postscript method of the canvas to get an Encapsulated PostScript (EPS) representation of the contents. Then, use `ImageMagick's Python bindings (PythonMagick or PythonMagickWand) to convert the EPS to a Windows Enhanced Metafile (EMF). Finally, copy it to the clipboard (e.g. using nosklo's solution) with the CF_ENHMETAFILE clipboard format.

like image 89
Adam Rosenfield Avatar answered Jan 30 '23 00:01

Adam Rosenfield