Write and test a function whose first line is
def drawOnCanvas(can, shape):
And which adds a shape represented by the dictionary shape to the tkinter Canvas can. The following fragment of
code illustrates the operation of the function:
from tkinter import * root = Tk() can = Canvas(root,width = 200, height = 100) can.pack() shape1 = {'bounds': [20, 20, 80, 50], 'kind':
'rect', 'fill': True} shape2 = {'bounds': [80, 50, 20, 35], 'kind': 'tri',
'fill': False} drawOnCanvas(can, shape1) drawOnCanvas(can, shape2) root.mainloop() |
Figure 5: Code Fragment Illustrating Use of drawOnCanvas
The code fragment would produce output as shown in Figure 6 below.
Figure 6: Output from Code in Figure 5
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 1 | 2 | 3 | 4 | 5 |