Technical data
Tcl/Tk and ModelSim
ModelSim EE Tutorial ModelSim EE Lessons
-
123
Example 2 - add a procedure that
g
ets called by a button push
Before you begin this example make sure you have completed "Preparing for the
Tcl/Tk examples" (p121).
In this example you will study a larger Tcl example, and add a procedure that gets
called by a button push.
This example will display all of the gif images in the images directory. Each
button has a binding attached to it for "enter" events, and a binding for a mouse
button press. When the mouse enters the button graphic, the image file name is
printed to the Main window. When the mouse button is pushed its "widget" name
will be printed to the Main window.
1
Build an image viewer by invoking this command, and calling this procedure:
source images.tcl
image_example
2
Drag the mouse across the buttons and notice what happens in the Main transcript.
Push one of the buttons; you will see an error dialog box. You can solve this
problem by modifying the
images.tcl
file.
3
To view the source file press the
See Source Code
button at the bottom of the image
display or invoke
notepad
at the Model
Sim
prompt:
notepad images.tcl
You’ll find that the
pushme
procedure is missing; it’s commented out in
images.tcl
.
4
Search for "proc push" using the
Edit > Find
menu selection in the notepad.
Remove the comments (the "#" symbols) to return the function to your source,
then close the image window with the
Destroy
button.
5
Once the
pushme
procedure is in place it will print its one parameter, the object name,
to the transcript.
After you have added the
pushme
procedure to your source, you need to resource
and rerun the Tcl procedure with these commands (use the up arrow to scroll
through the commands or type !source):
source images.tcl
image_example