Tcl/Tk Worksheet 2. ICT 11. For each of the following, attempt to write the code for
the command portion of the widget identified. Create names for the widgets ...
Tcl/Tk Worksheet 2
ICT 11
For each of the following, attempt to write the code for the command portion of the widget identified. Create names for the widgets and write them directly on the images for your reference. You should then write the code and produce a working version of the program depicted. Your programs do not have to look exactly like the ones shown. 1.
When one of the buttons is pushed, a random message is displayed saying either “You won!” or “You lost”.
2.
When the [Push:] button is pushed, a random number from 1 to 6 is chosen. The 6 labels keep track of each random number to see if one number is picked more than others. Write the command for the [Push:] button.
3.
When the [Deal:] button is pushed, 2 random numbers will be chosen (one for the computer and 1 for the player). As in the traditional card game “war”, whoever gets a higher “card” gets 1 point. Each time the button is pushed, generate 2 more random numbers and give a point to the winner.
4.
Write a “horserace” program that keeps a graph of the progress of the horses. Each time the [Race!] button is pushed, a random number is calculated between 1 and 6. If a 1 is picked, the green label next to the “Horse 1” is increased in width using the “config” command. Write the command for the [Race!] button.
5.
Write a Fortune telling program. Your program should have at least 10 different messages (none of them too crazy).
6.
Write a Minesweeper II program that has random numbers underneath the buttons.