Can Baran wrote: > Say, you have pan = Navcanvas.navcanvas(...) > handle = pan.Canvas.AddScaledText(...., "test", ..., font) > Now, I wanted to have a function which should give me the dimensions of > the text that I just placed. Something like this: > result = pan.TextExtent(handle, font) > and result would have the dimensions of the "test" in screen ( or > canvas) coordinates.
handle.BoundingBox Is the Bounding Box of the text in world coordinates. It is a BBox object, which is defined in floatcanvas.utilities.BBox. It is a subclass of a numpy array that looks like: [[MinX, MinY ], [MaxX, MaxY ]] so you can get it's elements like so: min_x = BB[0,0] max_y = BB[1,1] upper_left = BB[0] etc. You can also get it's dimensions: BB.Width BB.Height If you want the BB in pixel coords, you can do: Canvas.WorldToPixel(BB), but it's unlikely that you want that -- part of the point of FloatCanvas is that you don't have to think about pixel coords. All DrawObjects have a BoundingBox attribute, though the unscaled ones have zero-size bounding boxes, because the size of there bounding box changes as the Canvas is zoomed. However, I'm still curious as to why you need the size, as the Position argument lets you lay out the text in various ways, so you may not even need it. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [EMAIL PROTECTED] _______________________________________________ FloatCanvas mailing list [email protected] http://mail.mithis.com/cgi-bin/mailman/listinfo/floatcanvas
