Design notes for Sidebar Feature

Owen Taylor 2008-10-18

The basic linear flow of Reinteract worksheets works well for calculations: you do some calculations, show them, then you do other calculations based on those calculations, and so forth. But there are other tasks where it’s a trickier fit - often these tasks involve incremementally construction of an object by multiple calls with side effects. Consider trying to use Reinteract to experiment with the cairo drawing library. In the standard worksheet flow, it would look something like:

surface = cairo.ImageSurface(cairo.FORMAT_RGB24, 200, 200)
cr = cairo.Context(surface)
cr.set_source_rgba(1,1,1) # white
cr.paint()
cr.set_source_rgba(1,1,1) # black
cr.move_to(0, 0)
cr.line_to(0, 0)
cr.stroke()
surface
# Surface displays inline

(This example is hypothetical - as of Oct 20008, there’s no mechanism managing the side effects of the painting calls on the Context that affect the ImageSurface.) The main problem with this is simply one of positioning … the surface is below all the code modifying it and is likely to be off the bottom of the visible area. It’s also pretty unnatural that the way to incrementally work is to start off with:

surface = cairo.ImageSurface(cairo.FORMAT_RGB24, 200, 200)
cr = cairo.Context(surface)
# ... add stuff here ....
surface
# Surface displays inline

and add code in the middle. The basic idea of a sidebar is that you type:

cr = recairo.Context(200, 200)

and a sidebar pane opens to the right of the worksheet and an empty canvas is displayed there. Then subsequent drawing calls made on the Context object ”update” the canvas so it always shows the results at the end of the drawing commands in the worksheet.

Elaborations