Get pixels position of a Text object

Hello,

I want to get pixels position of a Text object on my imagine, but there isn't
any methods of this class to get them.

How can I do ?

Regards,

···

--
Romain Bignon - http://progs.coderz.info

http://www.inl.fr

You can use the t.get_window_extent() method of the text object, with
the caveat that this
only works *after* the canvas has been drawn, so you need to force a
draw first. Makre sure you use the same DPI in the figure and savefig
commands if you need these coords for working with hardcopy

from pylab import figure, show

fig = figure(figsize=(6,6), dpi=72)
ax = fig.add_subplot(111)
ax.plot([1,2,3])
t = ax.text(1,2,'hi')
fig.canvas.draw()
left, bottom, width, height = t.get_window_extent().get_bounds()

print left, bottom, width, height

fig.savefig('test', dpi=72) # make sure you use the same DPI if you save
show()

···

On 8/31/07, Romain Bignon <romain@...1712...> wrote:

Hello,

I want to get pixels position of a Text object on my imagine, but there isn't
any methods of this class to get them.

How can I do ?