|
From: Todd M. <jm...@st...> - 2004-09-13 17:53:25
|
On Mon, 2004-09-13 at 12:08, John Hunter wrote:
> >>>>> "Matt" == Matt Newville <new...@ca...> writes:
>
> Matt> I agree that it would not be that easy with TkAgg. I think
> Matt> you have to use Tkinter.Canvas.postscript() to get a
> Matt> representation of the whole canvas. Then you'd have to
> Matt> convert postscript to a bitmap that can be copied to the
> Matt> clipboard (using clipboard_copy() / clipboard_append()). I
> Matt> think that's not very easy, as PIL is not that good with
> Matt> postscript.
>
> Matt> It might be easier to switch to the Agg backend and create a
> Matt> bitmap that can then be copied to the clipboard. This looks
> Matt> possible, and might make a more uniform way to copy to
> Matt> clipboard.
>
> Matt> By the way, for the WXAgg backend, copy to the clipboard is
> Matt> fairly simple, as it already provides the bitmap: For a
> Matt> canvas = FigureCanvasWxAgg(...)
>
> Matt> This works: bmp = wx.BitmapDataObject()
> Matt> bmp.SetBitmap(canvas.bitmap) wx.TheClipboard.Open()
> Matt> wx.TheClipboard.SetData(bmp) wx.TheClipboard.Close()
>
> I don't know about how one accesses the operating system clipboard in
> tk or the other GUI toolkits (I assume this is platform dependent),
> but it is easy to get the bitmap from tkagg. FigureCanvasTkAgg
> derives from FigureCanvasAgg, which provides a method tostring_rgb.
> You should be able to use this to create a bitmap for copying to the
> clipboard.
That sounds pretty easy. I have two questions:
1. What is meant by "bitmap"? How standard is the format?
2. Is a "bitmap" the right format? What about EPS?
I guess that was 4.
Cheers,
Todd
>
> This is how wxagg's FigureCanvasWxAgg gets the bitmap in the first
> place
>
> def draw(self):
> """
> Render the figure using agg
> """
> DEBUG_MSG("draw()", 1, self)
>
> FigureCanvasAgg.draw(self)
> s = self.tostring_rgb()
> w = int(self.renderer.width)
> h = int(self.renderer.height)
> image = wxEmptyImage(w,h)
> image.SetData(s)
> self.bitmap = image.ConvertToBitmap()
>
> Hope this helps...
>
> Thanks for the wx example.
>
> JDH
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
> Project Admins to receive an Apple iPod Mini FREE for your judgement on
> who ports your project to Linux PPC the best. Sponsored by IBM.
> Deadline: Sept. 13. Go here: http://sf.net/ppc_contest.php
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
--
|