O'Reilly logo

Learning Perl/Tk by Nancy Walsh

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

9.5. Canvas Options

The options listed in this section affect the entire canvas widget and the items within it. Items are circles, lines, rectangles, text, or other widgets. These options act as you would expect them to (as explained in Chapter 3, for most options and in Chapter 6 for the scrollbar options): -background, -borderwidth, -cursor, -height, -highlightbackground, -highlightcolor, -highlightthickness, -relief, -takefocus, -width, -xscrollcommand, and -yscrollcommand.

9.5.1. New Options

When selecting items in the canvas with the mouse cursor, the canvas widget does calculations to determine if the mouse cursor is inside or outside the item. The -closeenough option controls how close the mouse must be to the item before it is considered inside the item. The default value for -closeenough is "1.0", which is 1.0 pixels away. Any floating point number is a valid value (and will always be in pixels) for -closeenough.

I discussed the -scrollregion option briefly in "The Scrollable Region" earlier in this chapter. It takes a list reference, and that list must contain four coordinates. The coordinates indicate a bounding region for the scrollable area in the canvas. The coordinates are in this order: [ minx, miny, maxx, maxy]. You can also think of the coordinates as if they were defining the [ left, top, right, bottom ] edges of the scrollable region.

Normally, the canvas widget limits the user to seeing only the area defined by the -scrollregion option. You can allow the ...

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