Turtle module – Saving an image

from tkinter import * # Python 3 #from Tkinter import * # Python 2 import turtle turtle.forward(100) ts = turtle.getscreen() ts.getcanvas().postscript(file=”duck.eps”) This will help you; I had the same problem, I Googled it, but solved it by reading the source of the turtle module. The canvas (tkinter) object has the postscript function; you can use … Read more

How to bind several key presses together in turtle graphics?

I’m skeptical that you can cleanly solve this coordinating variables between onkeypress() and onkeyrelease() events. (Though I’d be pleased to be shown otherwise.) I offer an alternate approach where key presses simply post move requests and a timer applies those requests, whether individual or doubled up: from turtle import Turtle, Screen win = Screen() flynn … Read more

Detecting collision in Python turtle game

This code seems to be more wishful thinking than actual programming: def is_collided_with(self, run): return self.rect.colliderect(run.rect) runner = run(10, 10, ‘my_run’) follower = follow(20, 10) if follow.is_collided_with(run): print ‘collision!’ Turtles don’t have a .rect() method. You can’t simply add a is_collided_with() method to an existing class with this def statement. There are no run() and … Read more