O'Reilly logo

Mastering Perl/Tk by Nancy Walsh, Stephen Lidie

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Retrieving Bounding Box Coordinates

When we talked about the scrolling region of a Canvas, we saw an example of the bbox method. The bboxmethod returns a list with four elements that define the area in which all the specified tags exist. The example used the special "all" tag, which refers to every item in the Canvas. This was how we used it to define our scrolling region. You can specify more than one tag/ID to search for as follows:

($x1, $y1, $x2, $y2) = $canvas->bbox("blue", "red");

Assuming that you have been assigning the tags "blue" and "red" to color items appropriately, this code would return the region in the Canvas that encloses all blue and red items.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required