Navigation Logo 12.6  Mouse Cursor Navigation Logo

 

 

All widget classes have a -cursor option which defines the appearance of the mouse cursor when it is over the subwindow that displays the widget.

Tk has some built-in cursors which you can access with this form of the -cursor option,

-cursor CURSOR_NAME 
Here are some possible values for CURSOR_NAME.

X_cursor, target, plus, tcross, crosshair, xterm, circle, man, gumby, mouse, spider, spraycan, pencil, arrow, center_ptr

Here is an example that creates and packs a frame in such a way that the mouse cursor will have the appearance specified by X_cursor when it is over the frame.

pack [frame .fr -width 1c -height 1c -cursor X_cursor]

The -cursor option has other variations that let you control colors and load your own bitmaps. See your on-line manual.

Exercise 12.6a

Create and display a frame which shows all of the cursors listed above – one at a time. Use the left mouse button as a trigger to cycle through the different cursors by finishing this bind command,
bind FRAME_WIDGET_PATH <Button-1> ...

Keep track of which cursor is being used by printing its name in the command window.

Solution

 

 

[Sample TK Application]
Author's Home Page
Navigation Logo [Book's Cover]
Order from Amazon.