[plt-scheme] GUIBuilder HOWTO

From: Corey Sweeney (corey.sweeney at gmail.com)
Date: Thu Sep 2 11:18:28 EDT 2004

On Tue, Aug 31, 2004 at 09:46:45AM -0700, Matthew Flatt wrote:
> At Tue, 31 Aug 2004 14:23:43 -0500, ctest at neural.dlsemc.com wrote:
> > I've written A HOWTO/Tutorial for guibuilder (for drscheme)
> This is neat!

Thanks :)

> You've gone through a lot of trouble to use a tool that I never
> finished, so the least I can do is fix the bugs...
> >       * Report the Guibuilder "save bug" rather then just
> >         try to work around it.
> Is this the bug where the Scheme name of a frame gets lost? I've
> exp-tagged a repair in CVS. Beware that files saved after the repair
> will not load correctly with the old code.

Yep, that's the one.

I think the guibuilder idea of the in-code gui windows is really cool.
 In fact after using for a hour, i have trouble imagining any other
way of doing it, and think this would be *perfect* for teaching to
people who are new to programming/scheme/drscheme...  well i think the
only people who it really isn't necicary for are people who have the
drscheme gui libraries memorizied. (or people writing quake in scheme)

I'm also thinking about devision of code in a functional sence.  If a
user makes most of the GUI components "relative functions", in the
sence that acording to the program writer, he percieves no state space
that changes from one function call to another, but acording to the
"relative function" writer, it's actually a procedure that changes
state *relative to the user interface*.  I'll illistrate with a
example:  As i am writing a program, I want to grab a file.  So i'll
pop up a "file chooser", which i want to return a filename.  I'll want
to think of this as a function.  Also he shouldn't have to know
anything about object systems, or the gui library.  However the guy
who implemented the file chooser, will want to change the default
directory to the last directory used.  I don't have this entirely
figured out yet.  I guess what i'm emphasizing is using functions over
procedures for *enhanced readability and understandability* not just
compiler optimizations.

After using it for a couple of days, I got a idea on how to take
things even farther, and that's when i started doing the "component
archetecture" thing.  I've got some ideas as to how we might make this
even more obvious to the new drscheme user.

I wanted to try some expirments for some other ways of doing
guibuilder, but got stopped at finding a good graphics library.  I'm
hoping to find a version of gtk hooks for drscheme 208.  But i should
post this as a sperate question to the list.

I'm working on a article which explains this and a lot more of my
ideas which can help make things easier on people.  I'll post a
annoucement when it's a little more developed.

> On the continuation trick: If I'm reading the code right, it exploits a
> bug in v20x, which permits certain continuation jumps that should
> instead be blocked (for the safety of the underlying event dispatcher).

Honestly, I don't know :)

When I had the problem, it just screamed continuation to me.  (then
again, what doesn't?)  I have no knowlege of "continuation blocking",
so perhaps I am exploiting a bug.  is it a bug in drscheme 208, or the
version of guibuilder? If it is a bug, and it gets fixed, i hope
someone will leave a flag in to do it the old way, so as to now break
my tutorial :)

And how do you block a continuation?  Is this a R5RS thing, or a
drscheme "special" thing?

> I think that you want something like:
>  (let ([sema (make-semaphore)]
>        [result #f])
>    ... ; Make the frame.
>        ; In the button callback to continue, `(semaphore-post sema)'
>        ;  and set! the result into `result'
>   (yield sema)
>   (close-window ...)
>   result)
> The `sema'/`yield' combination is essentially what happens with dialogs,
> where closing the dialog posts to the semaphore.
> Does something like that work for you?

I tried using dialog boxes, and it wasn't working.  I found my problem
now. Basic Idea:  I was capturing the variable that refered to the
frame before the frame was created.  I'll fix the dialog section of
the tutorial, and let everyone know when it's fixed.

> Matthew


Posted on the users mailing list.