turtle.onkeypress()

turtle.onkeypress(fun, key=None) Parameters: fun – a function with no arguments or None key – a string: key (e.g. “a”) or key-symbol (e.g. “space”) Bind fun to key-press event of key if key is given, or to any key-press-event if no key is given. Remark: in order to be able to register key-events, TurtleScreen must have focus. (See method listen().) >>> def f(): ... fd(50) ... >>> screen.onkey(f, "Up") >>> screen.listen()

turtle.onkey()

turtle.onkey(fun, key) turtle.onkeyrelease(fun, key) Parameters: fun – a function with no arguments or None key – a string: key (e.g. “a”) or key-symbol (e.g. “space”) Bind fun to key-release event of key. If fun is None, event bindings are removed. Remark: in order to be able to register key-events, TurtleScreen must have the focus. (See method listen().) >>> def f(): ... fd(50) ... lt(60) ... >>> screen.onkey(f, "Up") >>> screen.listen()

turtle.ondrag()

turtle.ondrag(fun, btn=1, add=None) Parameters: fun – a function with two arguments which will be called with the coordinates of the clicked point on the canvas num – number of the mouse-button, defaults to 1 (left mouse button) add – True or False – if True, a new binding will be added, otherwise it will replace a former binding Bind fun to mouse-move events on this turtle. If fun is None, existing bindings are removed. Remark: Every sequence of mouse-move-events on a turtle is prece

turtle.onclick()

turtle.onclick(fun, btn=1, add=None) Parameters: fun – a function with two arguments which will be called with the coordinates of the clicked point on the canvas num – number of the mouse-button, defaults to 1 (left mouse button) add – True or False – if True, a new binding will be added, otherwise it will replace a former binding Bind fun to mouse-click events on this turtle. If fun is None, existing bindings are removed. Example for the anonymous turtle, i.e. the procedural way: >

turtle.numinput()

turtle.numinput(title, prompt, default=None, minval=None, maxval=None) Parameters: title – string prompt – string default – number (optional) minval – number (optional) maxval – number (optional) Pop up a dialog window for input of a number. title is the title of the dialog window, prompt is a text mostly describing what numerical information to input. default: default value, minval: minimum value for input, maxval: maximum value for input The number input must be in the range minva

turtle.mode()

turtle.mode(mode=None) Parameters: mode – one of the strings “standard”, “logo” or “world” Set turtle mode (“standard”, “logo” or “world”) and perform reset. If mode is not given, current mode is returned. Mode “standard” is compatible with old turtle. Mode “logo” is compatible with most Logo turtle graphics. Mode “world” uses user-defined “world coordinates”. Attention: in this mode angles appear distorted if x/y unit-ratio doesn’t equal 1. Mode Initial turtle heading positive angles “st

turtle.mainloop()

turtle.mainloop() turtle.done() Starts event loop - calling Tkinter’s mainloop function. Must be the last statement in a turtle graphics program. Must not be used if a script is run from within IDLE in -n mode (No subprocess) - for interactive use of turtle graphics. >>> screen.mainloop()

turtle.lt()

turtle.lt(angle) Parameters: angle – a number (integer or float) Turn turtle left by angle units. (Units are by default degrees, but can be set via the degrees() and radians() functions.) Angle orientation depends on the turtle mode, see mode(). >>> turtle.heading() 22.0 >>> turtle.left(45) >>> turtle.heading() 67.0

turtle.listen()

turtle.listen(xdummy=None, ydummy=None) Set focus on TurtleScreen (in order to collect key-events). Dummy arguments are provided in order to be able to pass listen() to the onclick method.

turtle.left()

turtle.left(angle) turtle.lt(angle) Parameters: angle – a number (integer or float) Turn turtle left by angle units. (Units are by default degrees, but can be set via the degrees() and radians() functions.) Angle orientation depends on the turtle mode, see mode(). >>> turtle.heading() 22.0 >>> turtle.left(45) >>> turtle.heading() 67.0