Version 5 of Useful Basic TCL Formulas

Updated 2005-02-16 09:36:01 by suchenwi

Robert Abitbol There are a lot of basic TCL formulas which are needed and useful in a lot of programs. This is some of them. Since I am a beginner, please don't be shy and don't hesitate to contradict me if what I am saying is wrong! Thanks!

AM (16 february 2005) Just a matter of idiom: the common word for this seems to be idiom - formula makes me think of magic incantations or pseudo-scientific inventions in old movies :)

1) Association of files: protocol

- You want a function to behave like another? Protocol is your friend. Ex:

 wm protocol . WM_DELETE_WINDOW do.exit

Here we are asking the program to treat the user's clicking on the top right of the first stripe, as if it were an exit. Thus the user will be asked questions such as: "the file has not been saved. Save it?" etc. when he'll click on the X at the top of the screen.. In fact the sequence will be identical as the exit sentence. Mm! Very useful!


2) Calling a box with some text

- Calling a box with a text: easy! Ex:

 tk_messageBox -message "Sorry, this function isn't ready yet."}

The full function would be:

 proc preferences {} {
    tk_messageBox -message "Sorry, this function isn't ready yet. Come back later :-)"
 }

- More to come