[racket] toy graphical list editor

From: Marijn (hkBst at gentoo.org)
Date: Tue May 24 09:54:55 EDT 2011

Hi Matthew,

On 05/24/11 05:02, Matthew Flatt wrote:
> At Mon, 23 May 2011 16:04:24 +0200, Marijn wrote:
>> I'm trying to implement a toy graphical list editor program to get a
>> feel for GUI programming in racket. Basic idea is a graphical
>> representation of a list with text-field%s alternated with buttons to
>> insert items and on the side of each text-field% a button to remove that
>> item. When the program is destroyed it should print the constructed list
>> on the console (when started from one). My understanding so far calls
>> for a doubly-linked list to hold the items (and their graphical
>> manifestation), although this seems very unlispy... Is there a better way?
> My preference for this sort of problem is to abandon MVC and let the
> GUI represent the model. That is, to build the result list in this
> case, I'd traverse the GUI hierarchy to extract the elements.
> To keep the model separate, though, I don't have a better suggestion
> than a doubly-linked list.
>> Sample code showing graphical layout and rudimentary functioning of the
>> program is attached.
>> Side-question: why does pressing an insert-button resize the top-level
>> frame%?
> When a text field has a non-empty string as its initial value, the
> minimum width is based on the string. If the initial value is an empty
> string, then a default is used, and the default turns out to be wider
> than one character. The "insert" buttons create empty fields, while the
> three initial fields have non-empty initial content.

After changing all the values to "1", when pressing an insert-button
*sometimes* the window is resized horizontally (slightly larger width)
and *sometimes* the window flickers to slightly larger horizontally, but
remains the same width. According to `get-graphical-min-size' the
horizontal width stays constant at, for me, 58. I wrote another program
which exhibits this flickering behavior for me which I attached. Again
the size output seems to be fine, at least on the granularity
instrumented. Is this expected behavior?


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: flicker.rkt
URL: <http://lists.racket-lang.org/users/archive/attachments/20110524/cf7a0fd4/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.racket-lang.org/users/archive/attachments/20110524/cf7a0fd4/attachment.sig>

Posted on the users mailing list.