Visual programming, looking for graphics layer

Ian Bicking ianb at colorstudy.com
Wed Nov 13 22:25:43 EST 2002


All the language discussions got me to thinking, and I was thinking of
Logo and got a bit of an itch.  After implementing a little Logo
interpreter, I wanted to do something more novel and interesting, like
Boxer.  In the extremely likely case you don't know anything about
Boxer, the website is at:

  http://www.soe.berkeley.edu/boxer/

It's a neat teaching language, where it has some graphical ways to
present programming structure.  Sadly its only available for Macs, and I
don't know if development is active.  But I've put up a little graphic
taken from one of the papers (and fixed up a bit) to give a feel:

  http://colorstudy.com/tmp/boxer-capture.gif

Basically to indicate structure there are boxes (hence the name) that
contain code.  So the code:

def sum(number_list):
    number = 0
    for n in number_list:
        number += n
    return number

Might look like:

+------------------+
| sum(number_list) |
+------------------+--------------------+
|                                       |
| number = 0                            |
| for n in number_list +-------------+  |
|                      | number += n |  |
|                      +-------------+  |
| return number                         |
|                                       |
|  +--------+                           |
|  | number |                           |
| /----------\                          |
| | 0        |                          |
| \----------/                          |
|                                       |
+---------------------------------------+

Of course, in this case I use Python-like syntax, and some of the
semantics are kind of fuzzy.  Like "number" is initialized, but it's
value is also tracked (nice for debugging) -- it's as though every local
variable is a C-style static variable.  There's lots of details to be
worked out with the semantics, but that's not what I'm asking about
here.

The hard part is that this sort of layout is fairly hard to do.  Not
only do you have text inside different sorts of boxes, but an important
part of the language is that you also have non-text literals (like
colors and shapes, and even lists may be represented in a graphical
fashion).  All these need to be manipulatable.

I'm hoping to get some advice or pointers on something already available
that can make this easier.  I could use pygame, maybe even with pyui,
but that's still a long way from what I'd have to do for even the most
minimal functionality.  I've also had a hard time understanding pyui's
architecture -- there's something magic in there and I can't tell where
things actually get *done*... but I'm sure that's surmountable.  Maybe
that's where I should be looking.

Any of the GUI kits (Tkinter, wxWindows, etc) aren't nearly flexible
enough, except maybe things like Tk's canvas, or other equivalent
widgets.  Do any of these offer functionality that would help in making
this editing environment?

Looking forward to suggestions...
  Ian





More information about the Python-list mailing list