tcl Getting started with tcl The Hello, world program in Tcl (and Tk)


Example

The following code can be entered in a Tcl shell (tclsh), or into a script file and run through a Tcl shell:

puts "Hello, world!"

It gives the string argument Hello, world! to the command puts. The puts command writes its argument to standard out (your terminal in interactive mode) and adds a newline afterwards.


In a Tk-enabled shell, this variation can be used:

pack [button .b -text "Hello, world!" -command exit]

It creates a graphic button with the text Hello, world! and adds it to the application window. When pressed, the application exits.

A Tk-enabled shell is started as: wish Or using tclsh along with the following statement:

package require Tk