exit_sketch()#

Quits/stops/exits the program.

Examples#

1def draw():
2    py5.line(py5.mouse_x, py5.mouse_y, 50, 50)
3
4
5def mouse_pressed():
6    exit()

Description#

Quits/stops/exits the program. Programs without a draw() function stop automatically after the last line has run, but programs with draw() run continuously until the program is manually stopped or exit_sketch() is run.

Rather than terminating immediately, exit_sketch() will cause the Sketch to exit after draw() has completed (or after setup() completes if called during the setup() function).

For Python programmers, this is not the same as sys.exit(). Further, sys.exit() should not be used because closing out an application while draw() is running may cause a crash (particularly with P3D).

Underlying Processing method: exit

Syntax#

exit_sketch() -> None

Updated on November 12, 2021 11:30:58am UTC