Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
cursor text in tcl/expect

Posted by skumar003 (skumar003), 12 February 2003
Wahtis the syntax for implementing the display text once the mouse is over a button or toolbar.

I am looking for the button option. The book I have does not mention anything about it.

Posted by admin (Graham Ellis), 13 February 2003
You're probably looking for a bind command rather than an option to the button command.   Events ("happenings" if you like) can be set in three ways
1. Those which are automatically provided - for example, the changing of the colour of a button when you move over it
2. Those which are set by the component commands, using options such as -command and -textvariable.
3. The less predictable requirements, such as changing the text on one component when you move over another, which are typically set with a bind.

The following program puts up two buttons and a label.   When you move over the upper button, it switches text on the label on and off (and when you press the button, the text toggles between two possible values ...)


proc flip {} {
       global state feelings
       set state [expr 1 - $state]
       set word [lindex "Marmite Bovril" $state]
       set feelings [lindex "Yummmm!!!!!  {!!\ Yuk\ !!}" $state]
       .tog configure -text $word
       .feed config -text $feelings

# Tcl/Tk - Event demo

wm geometry . 300x200

set state 0
set feelings "Yummmm!!!!!"

button .demo -text done -command exit
button .tog -text Marmite -command flip
label .feed -text " " -font 12x24 -padx 10 -pady 10

bind .tog <Enter> {.feed config -text $feelings}
bind .tog <Leave> {.feed config -text " "}
pack .tog .feed .demo -fill both -expand true

Posted by skumar003 (skumar003), 13 February 2003
Thank you. This helps.

The text is shown when the cursor moves over a button on th eframe. Can we do it. Can we do it in the form of a bubble?

Like the message" move forward one page" when we move the mouse over forward in the browser netscape?


Posted by admin (Graham Ellis), 13 February 2003
Pop ups can be created as toplevel widgets in Tk ... I suggest you start by having a look through any manuals you have on Tk, which probably have a lot of charts and diagrams to help you, and then ask further if they leave any questions unanswered.

This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2014: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: • WEB: • SKYPE: wellho