Writing to the console
Although rarely used in live programs, the console is a valuable tool during initial development. It allows us to direct debugging information easily, without requiring the overhead of creating dialog boxes (covered later in this book). To allow us to display a console on systems that have no console, or to reveal a hidden console, Tcl provides the console
command. The console
command accepts four keywords as follows:
Keyword |
Interpretation |
---|---|
|
Evaluate the script argument as a Tcl script within the console interpreter. |
|
Hide the console. |
|
Display the console. |
|
Query OR modify the console title. |
The syntax is as follows:
console keyword argument
How to do it…
In the following example, we will hide the console and then create a set of buttons to display the console and to write a message. Enter the following commands:
1 % button .b text "Show Console" command {console show} 2 % button .c text "Message" command {puts "My Message...