Need urgent solution......................

Jeremy Bowers jerf at
Wed Jun 11 23:24:36 CEST 2003

On Wed, 11 Jun 2003 17:32:22 +0000, Suresh  Kumar wrote:

> Hi,
>    I am using python and tkinter. My question is a simple one. How 
> to find number of pixels that a text occupies in canvas? In 
> otherwords how can i get the width of the text whose width is not 
> set explicitly? I have placed a text, say "Hello World",  in the 
> canvas using "create_text" and want to find number pixels that it 
> occupies.

You want to look at the methods on the Font class, like "measure". See .

Also take a look at what the metrics method returns; IIRC it has the
height of the font in there, in case you need it.

I'd also like to echo the comments of others about asking better
questions; the more urgent the question the more important a direct, to
the point subject line is, making it more likely a knowledgeable person
will find it. I happen to know the answer though so I can actually give it

Good luck.

More information about the Python-list mailing list