Computer Science I for majors by James Tam |
Using the tkinter module write a Python program that will show randomly lit 'holiday lights'. Your program will create an animation window that contains three 'lights' are drawn using basic shapes: rectangles, ovals etc. and each shape is given a distinct fill color (see Figure 1). Lights will always be filled with some color (conversely none of the shapes be in an 'unfilled' state). In addition to drawing shapes, the program can create another window with a control button. Pressing the button will randomly change the color of the three lights (which is why you need to pick three distinct colors so your marker clearly make the determination that the colors are changing). Although you don't have to use the starting sample program (see "Python programs" below) you will find it handy when trying to create the animation and control window.
Figure 1: Holiday lights |
You are free to use any Python libraries/modules for this assignment. The tkinter module is of particular focus for this assignment.
There are two programs that were covered in tutorial that you find helpful for this assignment. You can find them in UNIX under: /home/231/tutorials/nov16_22 or directly via [link to tkinter examples]. The starting program in UNIX under: /home/231/assignments/mini_assignment5 or via [shortcut link].
Feature |
Maximum marks |
|
Draws 3 shapes | 3 | |
Each shape has distinctive fill color | 3 | |
Button events (maximum 6 marks) | 6 | |
Button reacts in some way to presses (e.g., output message to console): 1 mark | ||
Button press randomly colors the three shapes: full 6 marks | ||
TOTAL |
12 |
Raw score | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
Grade point | 4 | 3.7 | 3.3 | 3.0 | 2.7 | 2.3 | 2.0 | 1.7 | 1.3 | 1.0 | 0.7 | 0.5 | 0 |