py5coding / py5generator

Meta-programming project that creates the py5 library code.
https://py5coding.org/
GNU General Public License v3.0
52 stars 13 forks source link

Fix or update example code that makes assumptions about non-blocking `run_sketch()` #381

Closed hx2A closed 9 months ago

hx2A commented 11 months ago

From @villares on mastodon:

https://py5coding.org/reference/sketch_print_line_profiler_stats.html

Cheers @hx2A, this example assumes you are in an environment where py5.run_sketch() is non-blocking by default (the Jupyter Notebook environment if remember correctly). Maybe you should make and example where an event like a a key pressed triggers the stats printing?

There are probably other examples that make the same assumption.

hx2A commented 9 months ago

There are probably other examples that make the same assumption.

This is in 14 other places. For some of them, there isn't a way to re-write the examples to work if py5.run_sketch() is blocking. For those, I will change the example to use py5.run_sketch(block=False), which doesn't make any assumptions.

hx2A commented 9 months ago

This is now fixed.

The example for py5.print_line_profiler_stats() now uses the key_pressed() event.

http://dev.py5coding.org/reference/sketch_print_line_profiler_stats.html

Here are some examples of examples that now use py5.run_sketch(block=False) :

http://dev.py5coding.org/reference/sketch_is_ready.html http://dev.py5coding.org/reference/sketch_hot_reload_draw.html http://dev.py5coding.org/reference/sketch_finished.html