コード例 #1
0
def make_world(constructor):
    #constructor ~ Wobbler
    # create TurtleWorld
    world = TurtleWorld()
    world.delay = 2
    world.setup_run(
    )  #setup_run(self)  Adds a row of buttons for run, step, stop and clear.

    # make three Wobblers with different speed and clumsiness attributes
    colors = ['orange', 'green', 'purple']
    i = 1.0
    for color in colors:
        t = constructor(
            world, i, i * 30, color
        )  #Wobbler.__init__(self, world, speed=1, clumsiness=60, color='red')
        i += 0.5

    return world
コード例 #2
0
ファイル: turtle_example.py プロジェクト: wiyuwiyu/Swampy
#!/usr/bin/python
"""
This module is part of Swampy, a suite of programs available from
allendowney.com/swampy.

Copyright 2005 Allen B. Downey
Distributed under the GNU General Public License at gnu.org/licenses/gpl.html.

"""

from swampy.TurtleWorld import TurtleWorld, Turtle

# create the GUI
world = TurtleWorld(interactive=True)

# create the Turtle
turtle = Turtle()

# wait for the user to do something
world.mainloop()
コード例 #3
0
#!/usr/bin/python
"""
This module is part of Swampy, a suite of programs available from
allendowney.com/swampy.

Copyright 2005 Allen B. Downey
Distributed under the GNU General Public License at gnu.org/licenses/gpl.html.

"""

import swampy.World
from swampy.TurtleWorld import TurtleWorld, Turtle

import swampy.Lumpy
lumpy = Lumpy.Lumpy()
lumpy.opaque_class(World.Interpreter)
lumpy.make_reference()

world = TurtleWorld()
bob = Turtle(world)

lumpy.object_diagram()
lumpy.class_diagram()