PageRenderTime 27ms CodeModel.GetById 21ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/Demo/turtle/turtledemo_two_canvases.py

http://unladen-swallow.googlecode.com/
Python | 49 lines | 33 code | 10 blank | 6 comment | 8 complexity | 693806b578b39e24eed7d2304c25f49a MD5 | raw file
 1#!/usr/bin/python
 2## DEMONSTRATES USE OF 2 CANVASES, SO CANNOT BE RUN IN DEMOVIEWER!
 3"""turtle example: Using TurtleScreen and RawTurtle
 4for drawing on two distinct canvases.
 5"""
 6from turtle import TurtleScreen, RawTurtle, TK
 7
 8root = TK.Tk()
 9cv1 = TK.Canvas(root, width=300, height=200, bg="#ddffff")
10cv2 = TK.Canvas(root, width=300, height=200, bg="#ffeeee")
11cv1.pack()
12cv2.pack()
13
14s1 = TurtleScreen(cv1)
15s1.bgcolor(0.85, 0.85, 1)
16s2 = TurtleScreen(cv2)
17s2.bgcolor(1, 0.85, 0.85)
18
19p = RawTurtle(s1)
20q = RawTurtle(s2)
21
22p.color("red", "white")
23p.width(3)
24q.color("blue", "black")
25q.width(3)
26
27for t in p,q:
28    t.shape("turtle")
29    t.lt(36)
30
31q.lt(180)
32
33for i in range(5):
34    for t in p, q:
35        t.fd(50)
36        t.lt(72)
37for t in p,q:
38    t.lt(54)
39    t.pu()
40    t.bk(50)
41
42## Want to get some info?
43
44print s1, s2
45print p, q
46print s1.turtles()
47print s2.turtles()
48
49TK.mainloop()