Esempio n. 1
0
    if event.char in ['\n', '\r']:
        bob.teleport(-180, bob.y-size*3)
        bob.busy = False
        return

    try:
        if event.char == ' ':
            bob.draw_(size)
            bob.busy = False
            return
        method = getattr(bob, 'draw_' + event.char)
        method(size)
    except AttributeError:
        print 'I don\'t know how to draw an', event.char
        bob.busy = False
        return

    bob.skip(size/2)
    bob.busy = False

if __name__ == '__main__':
    world = TurtleWorld()
    bob = TyperTurtle()
    bob.delay = 0
    size = 22
    bob.busy = False
    bob.teleport(-180, 150)

    world.bind('<Key>', keypress)
    world.mainloop()
Esempio n. 2
0
        bob.busy = False
        return

    # figure out which function to call, and call it
    try:
        func = eval('draw_' + event.char)
    except NameError:
        print
        "I don't know how to draw an", event.char
        bob.busy = False
        return

    func(bob, size)

    skip(bob, size / 2)
    bob.busy = False


world = TurtleWorld()

# create and position the turtle
size = 20
bob = Turtle(world)
bob.delay = 0.01
bob.busy = False
teleport(bob, -180, 150)

# tell world to call keypress when the user presses a key
world.bind('<Key>', keypress)

world.mainloop()
Esempio n. 3
0
        bob.busy = False
        return

    # figure out which function to call, and call it
    try:
        func = eval("draw_" + event.char)
    except NameError:
        print "I don't know how to draw an", event.char
        bob.busy = False
        return

    func(bob, size)

    skip(bob, size / 2)
    bob.busy = False


world = TurtleWorld()

# create and position the turtle
size = 20
bob = Turtle(world)
bob.delay = 0.01
bob.busy = False
teleport(bob, -180, 150)

# tell world to call keypress when the user presses a key
world.bind("<Key>", keypress)

world.mainloop()