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?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
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.To use windows clipboard you must convert the image data to a format accepted by win api. Then, just use this function:
Where
clip_type
can bewin32clipboard.CF_BITMAP
,win32clipboard.CF_TIFF
or many others.