![]() |
![]() |
![]() |
![]() |
Example 2 - Execute a procedure using a push button
Before you begin this example make sure you have completed "Initial setup" .
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 (or invoking shell on UNIX). When the mouse button is pushed, its "widget" name will be printed to the Main window (or invoking shell on UNIX).
- Build an image viewer by invoking this command, and calling this procedure:
source images.tcl image_example- Drag the mouse across the buttons and notice what happens in the Main transcript (or invoking shell on UNIX).
Push one of the buttons; you will see an error dialog box. You can solve this problem by modifying the images.tcl file.
- To view the source file press the See Source Code button at the bottom of the image display or invoke notepad at the ModelSim prompt:
notepad images.tclYou'll find that the pushme procedure is missing; it's commented out in images.tcl.
Remove the comments (the "#" symbols) to return the function to your source, use File > Save to save the changes, then close the image window with the Destroy button.
- 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 do !source):
source images.tcl image_examplePress all the buttons and notice the object names in the Main transcript. Close the image example window when you're done.
![]() Model Technology Incorporated Voice: (503) 641-1340 Fax: (503)526-5410 www.model.com sales@model.com |
![]() |
![]() |
![]() |
![]() |