Use sys.settrace to animate Python code? (Evil ideas that cross one's mind...)

To make a GUI/text IDE work similarly to the Logo-style animated execution you'd need to make the Python code work more slowly than normal. You could probably hook up a sys.settrace that stops when you finish a given operation and waits on a message from the GUI that it's drawn the results (and waited for the next simulation tick).

To make it work with normal GUIs, though, you'd have to use something like a "drawing queue" to which the code appended the drawing operations (since most GUIs can't handle drawing from a background thread). With that you'd be able to re-render the whole drawing queue to get to the state for the next frame of the animation. That makes the process less "drillable" for the kids, though.

It would let you have a "speed" button, something to let you slow down the process so that you could debug something, or speed it up to process a complex operation.

Would be neat if you could suspend the frame in the sys.settrace function and then resume it at some later time, which would let you interleave the GUI and running code... continuations anyone? Anyway, just a thought as we finish packing up things for the move tomorrow.


  1. André Roberge

    André Roberge on 07/26/2007 6:57 a.m. #

    You might want to have a look at rur-ple ( I believe it sort of does what you are describing.

  2. Andrew Clunis

    Andrew Clunis on 07/27/2007 12:14 a.m. #

    Hey Mike,<br />
    <br />
    I really want to chat with you about this.<br />
    <br />
    I'm the guy responsible for the current Develop activity sitting on It was an interesting spike solution, but Develop needs to be revisited. It really needs more than one person to be working on it, and your ideas look super cool. Right now, all Develop does is use Python's built in AST parser to build a simple class browser. Really, though, I want to get away from the ugly (and annoying to write) hierarchical treeview visual metaphor. What to replace it with, though, is a tricky question.<br />
    <br />
    BTW, Guido himself might be working on adding proper class reloading to Python at some point, so OLPC's Develop activity will be able to do true smalltalk-style manipulation of the program as it runs in memory. Very cool stuff.<br />
    <br />
    The current wiki page about Develop, basically describes it how I envisioned it earlier this year. The source tree is broken (tsk, tsk, how un-agile of me).<br />
    <br />
    Please ping me (orospakr on irc, or via the email above).

Comments are closed.


Pingbacks are closed.