Python
Step-by-step simulations with plt.pause
In Basthon, plt.pause now animates Matplotlib figures: a loop can show a simulation being built step by step, in the console as in the notebook.
Pillow images in tkinter
Basthon's tkinter windows now show Pillow images, as on a computer: ImageTk.PhotoImage turns a Pillow image (or a file) into a tkinter image, to put in a Label, a Button or a Canvas. Its paste method replaces the image shown: ideal to see the effect of an image processing click after click.
ics
The ics module arrives in Basthon's Python kernel: it writes and reads calendars in the iCalendar format, the .ics files that every calendar understands (the phone's, the school's digital workspace, Thunderbird, Google Calendar…). A way to generate the schedule of a project or of a course, then import it into your calendar in a single click.
Sound with p5
Basthon's p5 module can now make sound, in isolated kernels as with the legacy kernel: p5.sound is loaded with p5.js. You can play sound files (loadSound), synthesize notes (Oscillator, MonoSynth, Envelope…) and analyse what you hear (FFT, Amplitude). The classes of p5.sound are used directly after from p5 import *.
The webcam with p5 in isolated kernels
After drawing, interactions and images, Basthon's p5 module gains the webcam in isolated kernels: createCapture(VIDEO) works as with the legacy kernel. The video can be shown below the drawing, or drawn on the canvas with image.
from p5 import *
capture = None
def setup():
global capture
createCanvas(320, 240)
capture = createCapture(VIDEO)
# the video is drawn on the canvas, not shown below
capture.hide()
def draw():
background(255)
# the size of the video is only known once the camera is open
if capture.width > 0:
image(capture, 0, 0, width, width * capture.height / capture.width)
run()To protect students, Basthon asks for a confirmation at each call of createCapture, on top of the browser's usual permission: a program cannot turn the camera on behind its user's back. The camera turns off when the drawing is replaced by another one or when the kernel restarts.
Playing videos (createVideo) and sound (p5.sound) are still reserved to the legacy kernel for now.