forked from AllenDowney/ThinkPython
-
Notifications
You must be signed in to change notification settings - Fork 0
/
canvas_demo.py
34 lines (20 loc) · 836 Bytes
/
canvas_demo.py
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
31
32
33
34
"""Solution to an exercise from
Think Python: An Introduction to Software Design
Copyright 2010 Allen B. Downey
License: GNU GPLv3 http://www.gnu.org/licenses/gpl.html
This program requires Gui.py, which is part of
Swampy; you can download it from thinkpython.com/swampy.
"""
from swampy.World import *
world = World()
canvas = world.ca(width=500, height=500, background='white')
bbox = [[-150,-110], [150, 110]]
canvas.rectangle(bbox, outline='purple', width=5, fill='green')
canvas.oval(bbox, outline='purple', width=5, fill='yellow')
canvas.circle([0,0], 100, outline='purple', width=5, fill='orange')
canvas.line(bbox, fill='purple', width=5)
photo = PhotoImage(file='allen.ppm')
image = canvas.image([0,0], image=photo)
bbox = image.bbox()
canvas.rectangle(bbox, outline='purple', width=5, fill=None)
wait_for_user()