Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Lib/lib-tk/turtle.py

    r2 r391  
    33# Version 1.0.1 - 24. 9. 2009
    44#
    5 # Copyright (C) 2006 - 2009  Gregor Lingl
     5# Copyright (C) 2006 - 2010  Gregor Lingl
    66# email: glingl@aon.at
    77#
     
    2828by Wally Feurzig and Seymour Papert in 1966.
    2929
    30 Imagine a robotic turtle starting at (0, 0) in the x-y plane. Give it
     30Imagine a robotic turtle starting at (0, 0) in the x-y plane. After an ``import turtle``, give it
    3131the command turtle.forward(15), and it moves (on-screen!) 15 pixels in
    3232the direction it is facing, drawing a line as it moves. Give it the
    33 command turtle.left(25), and it rotates in-place 25 degrees clockwise.
     33command turtle.right(25), and it rotates in-place 25 degrees clockwise.
    3434
    3535By combining together these and similar commands, intricate shapes and
     
    9797
    9898Behind the scenes there are some features included with possible
    99 extensions in in mind. These will be commented and documented elsewhere.
     99extensions in mind. These will be commented and documented elsewhere.
    100100
    101101"""
     
    336336            del _dict[ex]
    337337    for ex in exclude:
    338         if _dict.has_key(ex):
     338        if ex in _dict:
    339339            del _dict[ex]
    340340    for ex in __methods(fromClass):
    341         if _dict.has_key(ex):
     341        if ex in _dict:
    342342            del _dict[ex]
    343343
     
    784784        if not isinstance(self.cv, ScrolledCanvas):
    785785            return self.canvwidth, self.canvheight
    786         if canvwidth is None and canvheight is None and bg is None:
     786        if canvwidth is canvheight is bg is None:
    787787            return self.cv.canvwidth, self.cv.canvheight
    788788        if canvwidth is not None:
     
    812812    """Will be raised in TurtleScreen.update, if _RUNNING becomes False.
    813813
    814     Thus stops execution of turtle graphics script. Main purpose: use in
    815     in the Demo-Viewer turtle.Demo.py.
     814    This stops execution of a turtle graphics script.
     815    Main purpose: use in the Demo-Viewer turtle.Demo.py.
    816816    """
    817817    pass
     
    860860        >>> s = Shape("compound")
    861861        >>> s.addcomponent(poly, "red", "blue")
    862         ### .. add more components and then use register_shape()
     862        >>> # .. add more components and then use register_shape()
    863863        """
    864864        if self._type != "compound":
     
    959959
    960960        Example (for a TurtleScreen instance named screen):
    961         screen.clear()
     961        >>> screen.clear()
    962962
    963963        Note: this method is not available as function.
     
    10001000        'logo'
    10011001        """
    1002         if mode == None:
     1002        if mode is None:
    10031003            return self._mode
    10041004        mode = mode.lower()
     
    10311031        >>> screen.setworldcoordinates(-10,-0.5,50,1.5)
    10321032        >>> for _ in range(36):
    1033                 left(10)
    1034                 forward(0.5)
     1033        ...     left(10)
     1034        ...     forward(0.5)
    10351035        """
    10361036        if self.mode() != "world":
     
    11371137        1.0
    11381138        >>> screen.colormode(255)
    1139         >>> turtle.pencolor(240,160,80)
     1139        >>> pencolor(240,160,80)
    11401140        """
    11411141        if cmode is None:
     
    12051205        >>> dist = 2
    12061206        >>> for i in range(200):
    1207                 fd(dist)
    1208                 rt(90)
    1209                 dist += 2
     1207        ...     fd(dist)
     1208        ...     rt(90)
     1209        ...     dist += 2
    12101210        """
    12111211        if n is None:
     
    12341234
    12351235    def _incrementudc(self):
    1236         "Increment upadate counter."""
     1236        """Increment update counter."""
    12371237        if not TurtleScreen._RUNNING:
    12381238            TurtleScreen._RUNNNING = True
     
    13051305        and a Turtle instance named turtle):
    13061306
    1307         >>> screen.onclick(turtle.goto)
    1308 
    1309         ### Subsequently clicking into the TurtleScreen will
    1310         ### make the turtle move to the clicked point.
     1307        >>> screen.onclick(goto)
     1308        >>> # Subsequently clicking into the TurtleScreen will
     1309        >>> # make the turtle move to the clicked point.
    13111310        >>> screen.onclick(None)
    1312 
    1313         ### event-binding will be removed
    13141311        """
    13151312        self._onscreenclick(fun, btn, add)
     
    13251322        must have focus. (See method listen.)
    13261323
    1327         Example (for a TurtleScreen instance named screen
    1328         and a Turtle instance named turtle):
     1324        Example (for a TurtleScreen instance named screen):
    13291325
    13301326        >>> def f():
    1331                 fd(50)
    1332                 lt(60)
    1333 
    1334 
     1327        ...     fd(50)
     1328        ...     lt(60)
     1329        ...
    13351330        >>> screen.onkey(f, "Up")
    13361331        >>> screen.listen()
    13371332
    1338         ### Subsequently the turtle can be moved by
    1339         ### repeatedly pressing the up-arrow key,
    1340         ### consequently drawing a hexagon
    1341         """
    1342         if fun == None:
     1333        Subsequently the turtle can be moved by repeatedly pressing
     1334        the up-arrow key, consequently drawing a hexagon
     1335
     1336        """
     1337        if fun is None:
    13431338            if key in self._keys:
    13441339                self._keys.remove(key)
     
    13701365        >>> running = True
    13711366        >>> def f():
    1372                 if running:
    1373                         fd(50)
    1374                         lt(60)
    1375                         screen.ontimer(f, 250)
    1376 
    1377         >>> f()   ### makes the turtle marching around
     1367        ...     if running:
     1368        ...             fd(50)
     1369        ...             lt(60)
     1370        ...             screen.ontimer(f, 250)
     1371        ...
     1372        >>> f()   # makes the turtle marching around
    13781373        >>> running = False
    13791374        """
     
    13861381        picname -- a string, name of a gif-file or "nopic".
    13871382
    1388         If picname is a filename, set the corresponing image as background.
     1383        If picname is a filename, set the corresponding image as background.
    13891384        If picname is "nopic", delete backgroundimage, if present.
    13901385        If picname is None, return the filename of the current backgroundimage.
     
    14101405        canvwidth -- positive integer, new width of canvas in pixels
    14111406        canvheight --  positive integer, new height of canvas in pixels
    1412         bg -- colorstring or color-tupel, new backgroundcolor
     1407        bg -- colorstring or color-tuple, new backgroundcolor
    14131408        If no arguments are given, return current (canvaswidth, canvasheight)
    14141409
     
    14191414        Example (for a Turtle instance named turtle):
    14201415        >>> turtle.screensize(2000,1500)
    1421             ### e. g. to search for an erroneously escaped turtle ;-)
     1416        >>> # e. g. to search for an erroneously escaped turtle ;-)
    14221417        """
    14231418        return self._resize(canvwidth, canvheight, bg)
     
    14611456        """Set turtle-mode to 'standard', 'world' or 'logo'.
    14621457        """
    1463         if mode == None:
     1458        if mode is None:
    14641459            return self._mode
    14651460        if mode not in ["standard", "logo", "world"]:
     
    14961491        >>> turtle.heading()
    14971492        90
    1498         >>> turtle.degrees(400.0)  # angle measurement in gon
     1493
     1494        Change angle measurement unit to grad (also known as gon,
     1495        grade, or gradian and equals 1/100-th of the right angle.)
     1496        >>> turtle.degrees(400.0)
    14991497        >>> turtle.heading()
    15001498        100
     
    20022000        >>> turtle.pensize()
    20032001        1
    2004         turtle.pensize(10)   # from here on lines of width 10 are drawn
     2002        >>> turtle.pensize(10)   # from here on lines of width 10 are drawn
    20052003        """
    20062004        if width is None:
     
    24422440                RawTurtle.screens.append(self.screen)
    24432441        else:
    2444             raise TurtleGraphicsError("bad cavas argument %s" % canvas)
     2442            raise TurtleGraphicsError("bad canvas argument %s" % canvas)
    24452443
    24462444        screen = self.screen
     
    25142512        Example (for a Turtle instance named turtle):
    25152513        >>> while undobufferentries():
    2516                 undo()
     2514        ...     undo()
    25172515        """
    25182516        if self.undobuffer is None:
     
    25902588        >>> dist = 2
    25912589        >>> for i in range(200):
    2592                 turtle.fd(dist)
    2593                 turtle.rt(90)
    2594                 dist += 2
     2590        ...     turtle.fd(dist)
     2591        ...     turtle.rt(90)
     2592        ...     dist += 2
    25952593        """
    25962594        return self.screen.tracer(flag, delay)
     
    26872685        """Set/return turtle's stretchfactors/outline. Set resizemode to "user".
    26882686
    2689         Optinonal arguments:
     2687        Optional arguments:
    26902688           stretch_wid : positive number
    26912689           stretch_len : positive number
     
    27052703        >>> turtle.shapesize(outline=8)
    27062704        """
    2707         if stretch_wid is None and stretch_len is None and outline == None:
     2705        if stretch_wid is stretch_len is outline is None:
    27082706            stretch_wid, stretch_len = self._stretchfactor
    27092707            return stretch_wid, stretch_len, self._outlinewidth
     
    27612759        >>> turtle.tilt(45)
    27622760        >>> turtle.tiltangle()
    2763         >>>
    27642761        """
    27652762        tilt = -self._tilt * (180.0/math.pi) * self._angleOrient
     
    29612958        Example (for a Turtle instance named turtle):
    29622959        >>> for i in range(8):
    2963                 turtle.stamp(); turtle.fd(30)
     2960        ...     turtle.stamp(); turtle.fd(30)
    29642961        ...
    29652962        >>> turtle.clearstamps(2)
     
    29792976    def _goto(self, end):
    29802977        """Move the pen to the point end, thereby drawing a line
    2981         if pen is down. All other methodes for turtle movement depend
     2978        if pen is down. All other methods for turtle movement depend
    29822979        on this one.
    29832980        """
     
    30773074        # Turtle now at position old,
    30783075        self._position = old
    3079         ##  if undo is done during crating a polygon, the last vertex
    3080         ##  will be deleted. if the polygon is entirel deleted,
    3081         ##  creatigPoly will be set to False.
     3076        ##  if undo is done during creating a polygon, the last vertex
     3077        ##  will be deleted. if the polygon is entirely deleted,
     3078        ##  creatingPoly will be set to False.
    30823079        ##  Polygons created before the last one will not be affected by undo()
    30833080        if self._creatingPoly:
     
    32193216        """Draw a dot with diameter size, using color.
    32203217
    3221         Optional argumentS:
     3218        Optional arguments:
    32223219        size -- an integer >= 1 (if given)
    32233220        color -- a colorstring or a numeric color tuple
     
    34283425
    34293426        >>> def turn(x, y):
    3430                 left(360)
    3431 
    3432         >>> onclick(turn) # Now clicking into the turtle will turn it.
     3427        ...     left(360)
     3428        ...
     3429        >>> onclick(turn)  # Now clicking into the turtle will turn it.
    34333430        >>> onclick(None)  # event-binding will be removed
    34343431        """
     
    34463443        Example (for a MyTurtle instance named joe):
    34473444        >>> class MyTurtle(Turtle):
    3448                 def glow(self,x,y):
    3449                         self.fillcolor("red")
    3450                 def unglow(self,x,y):
    3451                         self.fillcolor("")
    3452 
     3445        ...     def glow(self,x,y):
     3446        ...             self.fillcolor("red")
     3447        ...     def unglow(self,x,y):
     3448        ...             self.fillcolor("")
     3449        ...
    34533450        >>> joe = MyTurtle()
    34543451        >>> joe.onclick(joe.glow)
    34553452        >>> joe.onrelease(joe.unglow)
    3456         ### clicking on joe turns fillcolor red,
    3457         ### unclicking turns it to transparent.
     3453
     3454        Clicking on joe turns fillcolor red, unclicking turns it to
     3455        transparent.
    34583456        """
    34593457        self.screen._onrelease(self.turtle._item, fun, btn, add)
     
    34743472        >>> turtle.ondrag(turtle.goto)
    34753473
    3476         ### Subsequently clicking and dragging a Turtle will
    3477         ### move it across the screen thereby producing handdrawings
    3478         ### (if pen is down).
     3474        Subsequently clicking and dragging a Turtle will move it
     3475        across the screen thereby producing handdrawings (if pen is
     3476        down).
    34793477        """
    34803478        self.screen._ondrag(self.turtle._item, fun, btn, add)
     
    35233521        Example (for a Turtle instance named turtle):
    35243522        >>> for i in range(4):
    3525                 turtle.fd(50); turtle.lt(80)
    3526 
     3523        ...     turtle.fd(50); turtle.lt(80)
     3524        ...
    35273525        >>> for i in range(8):
    3528                 turtle.undo()
     3526        ...     turtle.undo()
     3527        ...
    35293528        """
    35303529        if self.undobuffer is None:
     
    36893688
    36903689class Turtle(RawTurtle):
    3691     """RawTurtle auto-crating (scrolled) canvas.
     3690    """RawTurtle auto-creating (scrolled) canvas.
    36923691
    36933692    When a Turtle object is created or a function derived from some
     
    37293728                default value is turtle_docstringdict
    37303729
    3731     Has to be called explicitely, (not used by the turtle-graphics classes)
     3730    Has to be called explicitly, (not used by the turtle-graphics classes)
    37323731    The docstring dictionary will be written to the Python script <filname>.py
    37333732    It is intended to serve as a template for translation of the docstrings
Note: See TracChangeset for help on using the changeset viewer.