Technical data

Tcl/Tk and ModelSim
122
-
ModelSim EE Lessons ModelSim EE Tutorial
Example 1 - create a "hello world" button wid
g
et
Before you begin the examples make sure you have completed "Preparing for the
Tcl/Tk examples" (p121).
In this example you will study a "hello world" button that prints a message when
pressed.
1
Source the Tcl file from the Model
Sim
prompt:
source hello.tcl
then run the procedure defined within
hello.tcl
:
hello_example
The file
hello.tcl
was read into the VSIM Tcl interpreter. The instructions in
hello_example
procedure were then executed by VSIM, and "Hello World" was
printed to the Main transcript. Selecting the button will print the message again.
You’ve just created your first top-level widget!
2
Invoke the
hello_example
procedure again and notice how the new button replaces the
original button. The procedure destroyed the first button and created the new one. Get
a closer look at the source Tcl file with the
notepad
:
notepad hello.tcl
Close the hello_example window when you’re done.