[plt-scheme] middle ground between MrEd and gui/draw teachpacks?

From: Prabhakar Ragde (plragde at uwaterloo.ca)
Date: Wed Feb 9 10:56:18 EST 2005

A seminar here brings in girls (Grades 9/10 or so) identified by their
math teachers as possibly having CS aptitude but not having chosen to
take any courses yet, and tries to show them something of the
field. They do some programming labs, and what is being used right now
is Tck/Tk (edited in Notepad, run from the command line). They modify
a drawing program of about 200 lines. It violates my precepts of "as
little magic as possible", but I suppose in a week there has to be
some magic. Still, that strikes me as too much.

I decided to see what DrScheme could offer as an alternative, and did
two things. One was to write a comparable program using the full MrEd
toolkit (which required quickly learning the basics of classes, all
stuff I have been putting off too long); the other was to see if I
could adhere more to the safe-sandbox approach of HtDP and combine
functions from the gui.ss and draw.ss teachpacks.

The former is overkill, I think, though I believe it is still more
readable and intelligently modifiable than the Tcl program. The latter
is too simple; the two packs do not play as well together as I'd
like. This leads me to the following questions:

1) How hard would it be to integrate the canvas from draw.ss into a
   window created by gui.ss? The problem is that the canvas and GUI
   window are separate right now, and only one is "on top". It's
   awkward to have to keep raising one or the other.

2) Failing that, is it possible for me to write functions which bring
   one window or another to the top? I want to be able to press a
   "Draw" button on the GUI and have the canvas come to the top ready
   for a mouse click. Then after the two clicks, it will draw the line
   and the GUI window will come back on top.

3) Since this is a drawing program, I try to use (wait-on-mouse-click)
   to get, say, two positions to define a line. But this seems to
   queue up mouse events in advance. If I click several times on the
   canvas, and then press the "Draw" button which gets two clicks and
   draws the line, it will use past clicks, not future ones, and draws
   the line immediately.

I can see I'll need to write my own teachpack, but I'm hoping to avoid
having to augment gui.ss with make-canvas, drawing, and mouse-handling
routines. Thanks. --PR

Posted on the users mailing list.