Even More Options

Even More Options That Affect The Behavior Of Labels

You can control which cursor gets displayed while the mouse pointer is over the label, using the -cursor option. To see this, move the mouse pointer over the labels below and see what happens:



There are about eighty built in cursors in Tk. You can even control the foreground and background colors of the cursor (move the mouse pointer over the labels to see this):



You can select which font your text should appear in with the -font option. Fonts are specified with X Windows font syntax, so it's a bit complicated. Check this page for a full description of fonts:



The last thing I'll show on this page is that you can modify the behavior of the label widget through bindings. These are actions, attached to the widget, that fire when certain events occur on the display. Here's how you write a binding:

label .l -text Hello!
bind .l <Enter> enter
bind .l <Leave> leave


I haven't shown the definitions of the enter and leave procedures; try to figure out what they do, and then check yourself against the Tclet source!

Here's another example of wild things you can do with bindings and timers:





comments?