jmiller@...86... wrote:
I took a quick look at this and my impression is that clipboard support
must be explicitly added to the TkAgg backend and AFIK has not been. My
guess is that this is a wider reaching problem than TkAgg and it should
go into the list of future enhancements for matplotlib.
Regards,
Todd
It sounds more complicated than I thought. Indeed I was searching for existing solutions that would copy the window contents into clipboard. I know it is quite easy to do with Tcl/Tk and the BLT extension or something similar. You just call a function with the window path as arg and your clipboard is filled. This is why I focused on TkAgg.
Thanks.
JM.
Hi,
It sounds more complicated than I thought. Indeed I was
searching for existing solutions that would copy the window
contents into clipboard. I know it is quite easy to do with
Tcl/Tk and the BLT extension or something similar. You just call
a function with the window path as arg and your clipboard is
filled. This is why I focused on TkAgg.
I agree that it would not be that easy with TkAgg. I think you
have to use Tkinter.Canvas.postscript() to get a representation of
the whole canvas. Then you'd have to convert postscript to a
bitmap that can be copied to the clipboard (using clipboard_copy()
/ clipboard_append()). I think that's not very easy, as PIL is
not that good with postscript.
It might be easier to switch to the Agg backend and create a
bitmap that can then be copied to the clipboard. This looks
possible, and might make a more uniform way to copy to clipboard.
By the way, for the WXAgg backend, copy to the clipboard is fairly
simple, as it already provides the bitmap: For a
canvas = FigureCanvasWxAgg(...)
This works:
bmp = wx.BitmapDataObject()
bmp.SetBitmap(canvas.bitmap)
wx.TheClipboard.Open()
wx.TheClipboard.SetData(bmp)
wx.TheClipboard.Close()
Hope that helps,
--Matt