The Tkinter library folder \lib-tk contains a module called turtle. You can import this module and experiment with turtle graphics. Tell the turtle to move and draw circles, lines, rectangles and more, and watch it, as it performs on a Tkinter canvas. In typical turtle fashion it moves at its own animated speed.
Turtle Graphics (Python)
# the turtle module provides turtle graphics primitives, it uses a Tkinter canvas
# turtle is part of the Tkinter library (lib-tk)
# tested with Python24 vegaseat 30jun2005
from turtle import *
import time
# pen/turtle starts at the center (x=0, y=0) of the turtle display area
color("green")
# pen up, don't draw
up()
# centers the circle
goto(0,-50)
# pen down, draw
down()
# radius=50 center is 50 radius units above the turtle
circle(50)
up()
# center the turtle again
goto(0,0)
down()
# draw blue 100x100 squares
color("blue")
for deg in range(0, 61, 6):
right(90 + deg)
forward(100)
right(90)
forward(100)
right(90)
forward(100)
right(90)
forward(100)
up()
goto(-150,-120)
color("red")
write("Done!")
time.sleep(5) # wait 5 seconds
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
kvutza 0 Newbie Poster
CoatsyJnr 0 Newbie Poster
Ene Uran 638 Posting Virtuoso
woooee 814 Nearly a Posting Maven
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.