diff -r 49017c391564 Lib/turtle.py --- a/Lib/turtle.py Wed Mar 19 10:07:26 2014 +0000 +++ b/Lib/turtle.py Tue Jul 08 22:44:47 2014 -0400 @@ -2033,138 +2033,6 @@ self._shapetrafo = (1., 0., 0., 1.) self._outlinewidth = 1 - def resizemode(self, rmode=None): - """Set resizemode to one of the values: "auto", "user", "noresize". - - (Optional) Argument: - rmode -- one of the strings "auto", "user", "noresize" - - Different resizemodes have the following effects: - - "auto" adapts the appearance of the turtle - corresponding to the value of pensize. - - "user" adapts the appearance of the turtle according to the - values of stretchfactor and outlinewidth (outline), - which are set by shapesize() - - "noresize" no adaption of the turtle's appearance takes place. - If no argument is given, return current resizemode. - resizemode("user") is called by a call of shapesize with arguments. - - - Examples (for a Turtle instance named turtle): - >>> turtle.resizemode("noresize") - >>> turtle.resizemode() - 'noresize' - """ - if rmode is None: - return self._resizemode - rmode = rmode.lower() - if rmode in ["auto", "user", "noresize"]: - self.pen(resizemode=rmode) - - def pensize(self, width=None): - """Set or return the line thickness. - - Aliases: pensize | width - - Argument: - width -- positive number - - Set the line thickness to width or return it. If resizemode is set - to "auto" and turtleshape is a polygon, that polygon is drawn with - the same line thickness. If no argument is given, current pensize - is returned. - - Example (for a Turtle instance named turtle): - >>> turtle.pensize() - 1 - >>> turtle.pensize(10) # from here on lines of width 10 are drawn - """ - if width is None: - return self._pensize - self.pen(pensize=width) - - - def penup(self): - """Pull the pen up -- no drawing when moving. - - Aliases: penup | pu | up - - No argument - - Example (for a Turtle instance named turtle): - >>> turtle.penup() - """ - if not self._drawing: - return - self.pen(pendown=False) - - def pendown(self): - """Pull the pen down -- drawing when moving. - - Aliases: pendown | pd | down - - No argument. - - Example (for a Turtle instance named turtle): - >>> turtle.pendown() - """ - if self._drawing: - return - self.pen(pendown=True) - - def isdown(self): - """Return True if pen is down, False if it's up. - - No argument. - - Example (for a Turtle instance named turtle): - >>> turtle.penup() - >>> turtle.isdown() - False - >>> turtle.pendown() - >>> turtle.isdown() - True - """ - return self._drawing - - def speed(self, speed=None): - """ Return or set the turtle's speed. - - Optional argument: - speed -- an integer in the range 0..10 or a speedstring (see below) - - Set the turtle's speed to an integer value in the range 0 .. 10. - If no argument is given: return current speed. - - If input is a number greater than 10 or smaller than 0.5, - speed is set to 0. - Speedstrings are mapped to speedvalues in the following way: - 'fastest' : 0 - 'fast' : 10 - 'normal' : 6 - 'slow' : 3 - 'slowest' : 1 - speeds from 1 to 10 enforce increasingly faster animation of - line drawing and turtle turning. - - Attention: - speed = 0 : *no* animation takes place. forward/back makes turtle jump - and likewise left/right make the turtle turn instantly. - - Example (for a Turtle instance named turtle): - >>> turtle.speed(3) - """ - speeds = {'fastest':0, 'fast':10, 'normal':6, 'slow':3, 'slowest':1 } - if speed is None: - return self._speed - if speed in speeds: - speed = speeds[speed] - elif 0.5 < speed < 10.5: - speed = int(round(speed)) - else: - speed = 0 - self.pen(speed=speed) - def color(self, *args): """Return or set the pencolor and fillcolor. @@ -2211,120 +2079,6 @@ else: return self._color(self._pencolor), self._color(self._fillcolor) - def pencolor(self, *args): - """ Return or set the pencolor. - - Arguments: - Four input formats are allowed: - - pencolor() - Return the current pencolor as color specification string, - possibly in hex-number format (see example). - May be used as input to another color/pencolor/fillcolor call. - - pencolor(colorstring) - s is a Tk color specification string, such as "red" or "yellow" - - pencolor((r, g, b)) - *a tuple* of r, g, and b, which represent, an RGB color, - and each of r, g, and b are in the range 0..colormode, - where colormode is either 1.0 or 255 - - pencolor(r, g, b) - r, g, and b represent an RGB color, and each of r, g, and b - are in the range 0..colormode - - If turtleshape is a polygon, the outline of that polygon is drawn - with the newly set pencolor. - - Example (for a Turtle instance named turtle): - >>> turtle.pencolor('brown') - >>> tup = (0.2, 0.8, 0.55) - >>> turtle.pencolor(tup) - >>> turtle.pencolor() - '#33cc8c' - """ - if args: - color = self._colorstr(args) - if color == self._pencolor: - return - self.pen(pencolor=color) - else: - return self._color(self._pencolor) - - def fillcolor(self, *args): - """ Return or set the fillcolor. - - Arguments: - Four input formats are allowed: - - fillcolor() - Return the current fillcolor as color specification string, - possibly in hex-number format (see example). - May be used as input to another color/pencolor/fillcolor call. - - fillcolor(colorstring) - s is a Tk color specification string, such as "red" or "yellow" - - fillcolor((r, g, b)) - *a tuple* of r, g, and b, which represent, an RGB color, - and each of r, g, and b are in the range 0..colormode, - where colormode is either 1.0 or 255 - - fillcolor(r, g, b) - r, g, and b represent an RGB color, and each of r, g, and b - are in the range 0..colormode - - If turtleshape is a polygon, the interior of that polygon is drawn - with the newly set fillcolor. - - Example (for a Turtle instance named turtle): - >>> turtle.fillcolor('violet') - >>> col = turtle.pencolor() - >>> turtle.fillcolor(col) - >>> turtle.fillcolor(0, .5, 0) - """ - if args: - color = self._colorstr(args) - if color == self._fillcolor: - return - self.pen(fillcolor=color) - else: - return self._color(self._fillcolor) - - def showturtle(self): - """Makes the turtle visible. - - Aliases: showturtle | st - - No argument. - - Example (for a Turtle instance named turtle): - >>> turtle.hideturtle() - >>> turtle.showturtle() - """ - self.pen(shown=True) - - def hideturtle(self): - """Makes the turtle invisible. - - Aliases: hideturtle | ht - - No argument. - - It's a good idea to do this while you're in the - middle of a complicated drawing, because hiding - the turtle speeds up the drawing observably. - - Example (for a Turtle instance named turtle): - >>> turtle.hideturtle() - """ - self.pen(shown=False) - - def isvisible(self): - """Return True if the Turtle is shown, False if it's hidden. - - No argument. - - Example (for a Turtle instance named turtle): - >>> turtle.hideturtle() - >>> print turtle.isvisible(): - False - """ - return self._shown - def pen(self, pen=None, **pendict): """Return or set the pen's attributes. @@ -2450,8 +2204,30 @@ -scx*sa, scy*(ca - shf*sa)) self._update() -## three dummy methods to be implemented by child class: - +## dummy methods to be implemented by child class: + + def resizemode(self, rmode=None): + """dummy method - to be overwritten by child class""" + def pensize(self, width=None): + """dummy method - to be overwritten by child class""" + def penup(self): + """dummy method - to be overwritten by child class""" + def pendown(self): + """dummy method - to be overwritten by child class""" + def isdown(self): + """dummy method - to be overwritten by child class""" + def speed(self, speed=None): + """dummy method - to be overwritten by child class""" + def pencolor(self, *args): + """dummy method - to be overwritten by child class""" + def fillcolor(self, *args): + """dummy method - to be overwritten by child class""" + def showturtle(self): + """dummy method - to be overwritten by child class""" + def hideturtle(self): + """dummy method - to be overwritten by child class""" + def isvisible(self): + """dummy method - to be overwritten by child class""" def _newLine(self, usePos = True): """dummy method - to be overwritten by child class""" def _update(self, count=True, forced=False):