We have created some programs with examples of how to set timers, use event handlers, and draw shapes in our Bryton editor. All teachers and students can fork a copy of the programs to try out the code!
If you would like to add this into existing assignments, you can create a custom assignment! You can also fork the program to your sandbox and assign it to your class from there.
Timers
This program shows how to call a function on a delay using timer.set_timeout
and timer.set_interval
. You can check out the program here.
This program shows how to create a "click to pause" timer in Brython. You can check out the code here.
Event Handlers
X and Y coordinate on mouseMove
This code will allow you to track mouse movement event method similar to mouseMoveMethod()
in JavaScript Graphics. You can check out the code here.
Removing Handlers
This program shows how to remove event handlers after an event.
Click Image for Effect
Click image for effect will add images to a canvas and do different things based on which image the user clicks in CSP / Brython. You can check out the code here.
Lines and Shapes in Brython
Lines at Angles
This program will show you how to draw a line in Brython and use a formula in a function to set the angles. You can check out the code here.
Shapes
This program will show you how to draw an ellipse, circle, ranuculoid, and fill in or outline them. You can check out the code here.
Still have questions? Contact our team at hello@codehs.com to learn more!