Getting the Size of a Character

The bbox method returns a list containing four items that describe the box around the character at index:

($x, $y, $w, $h) = $text->bbox(index);

The first two items returned are the x and y coordinates of the upper-left corner. The last two are the width and height of the box. The bounding box describes only the visible portion of the character, so if it is half hidden or not visible at all, the values returned will reflect this.

Get Mastering Perl/Tk now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.