reset_py5()#

Reset the py5 module’s current Sketch instance.

Examples#

 1import py5
 2
 3assert py5.is_ready
 4first_sketch = py5.get_current_sketch()
 5py5.run_sketch(block=False)
 6py5.exit_sketch()
 7assert py5.is_dead
 8py5.reset_py5()
 9assert py5.is_ready
10second_sketch = py5.get_current_sketch()
11assert first_sketch is not second_sketch

Description#

Reset the py5 module’s current Sketch instance.

When coding py5 in module mode, a Sketch instance is created on your behalf that is referenced within the py5 module itself. That Sketch is called the “Current Sketch.” If the current Sketch exits, it will be in a dead state and cannot be re-run. reset_py5() will discard that exited Sketch instance and replace it with a new one in the ready state.

If reset_py5() is called when the current Sketch is in the ready or running states, it will do nothing and return False. If reset_py5() is called when the current Sketch is in the dead state, reset_py5() will replace it and return True.

Syntax#

reset_py5() -> bool

Updated on September 11, 2021 16:51:34pm UTC