From: Matt N. <new...@ca...> - 2004-09-13 16:39:12
|
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 |