[Python-checkins] python/dist/src/Lib/lib-tk turtle.py,1.7,1.8
gvanrossum@users.sourceforge.net
gvanrossum@users.sourceforge.net
Mon, 23 Sep 2002 09:55:07 -0700
Update of /cvsroot/python/python/dist/src/Lib/lib-tk
In directory usw-pr-cvs1:/tmp/cvs-serv18602
Modified Files:
turtle.py
Log Message:
Add the bulk of SF patch 595111 by Attila Babo.
This adds new methods heading(), setheading(), position(),
window_width(), window_height(), setx(), and sety(), to make this more
functionality-compatible with Logo turtle graphics (Attila's last
words, not mine :-). I had to fix the sety() code which was broken in
Attila's patch.
I'm not adopting the functionality change that Attila claimed was a
bugfix (no output without tracing), because I disagree that it's a
bug.
Index: turtle.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/turtle.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** turtle.py 22 Sep 2002 13:00:26 -0000 1.7
--- turtle.py 23 Sep 2002 16:55:05 -0000 1.8
***************
*** 3,6 ****
--- 3,7 ----
from math import * # Also for export
import Tkinter
+
class Error(Exception):
pass
***************
*** 54,58 ****
self._draw_turtle()
-
def tracer(self, flag):
self._tracing = flag
--- 55,58 ----
***************
*** 119,123 ****
self._draw_turtle()
-
def write(self, arg, move=0):
x, y = start = self._position
--- 119,122 ----
***************
*** 201,204 ****
--- 200,237 ----
self._path.append(self._position)
self._draw_turtle()
+
+ def heading(self):
+ return self._angle
+
+ def setheading(self, angle):
+ self._angle = angle
+ self._draw_turtle()
+
+ def window_width(self):
+ width = self._canvas.winfo_width()
+ if width <= 1: # the window isn't managed by a geometry manager
+ width = self._canvas['width']
+ return width
+
+ def window_height(self):
+ height = self._canvas.winfo_height()
+ if height <= 1: # the window isn't managed by a geometry manager
+ height = self._canvas['height']
+ return height
+
+ def position(self):
+ x0, y0 = self._origin
+ x1, y1 = self._position
+ return [x1-x0, -y1+y0]
+
+ def setx(self, xpos):
+ x0, y0 = self._origin
+ x1, y1 = self._position
+ self._goto(x0+xpos, y1)
+
+ def sety(self, ypos):
+ x0, y0 = self._origin
+ x1, y1 = self._position
+ self._goto(x1, y0-ypos)
def goto(self, *args):
***************
*** 327,330 ****
--- 360,370 ----
def circle(radius, extent=None): _getpen().circle(radius, extent)
def goto(*args): apply(_getpen().goto, args)
+ def heading(): return _getpen().heading()
+ def setheading(angle): _getpen().setheading(angle)
+ def position(): return _getpen().position()
+ def window_width(): return _getpen().window_width()
+ def window_height(): return _getpen().window_height()
+ def setx(xpos): _getpen().setx(xpos)
+ def sety(ypos): _getpen().sety(ypos)
def demo():