[plt-scheme] GUI editor simple example

From: Hugh Myers (hsmyers at gmail.com)
Date: Sat Jul 4 13:10:28 EDT 2009

Changing fonts always seems to be more complicated than it needs to
be! :) Much thanks for the mini-example and info.

--hsm

On Sat, Jul 4, 2009 at 7:47 AM, Matthew Flatt<mflatt at cs.utah.edu> wrote:
> At Sat, 4 Jul 2009 01:44:42 -0600, Hugh Myers wrote:
>> Given:
>>
>> (define f (new frame% [label "Simple Edit"]
>>                         [width 200]
>>                         [height 200]))
>>   (define c (new editor-canvas% [parent f]))
>>   (define t (new text%))
>>   (send c set-editor t)
>>
>> How do I control the initial font?
>
> Setting the font is more complicated than it should be. You have to
> create a `style-delta%' (which has a poor API), and then apply the
> style delta with `change-style'.
>
> For example, to change the font to size 20:
>
>  (send t change-style (make-object style-delta% 'change-size 20))
>
> To set the font to "Times":
>
>  (send t change-style (send (make-object style-delta%)
>                            set-delta-face "Times"))
>
>> How do I insert a line of text?
>
> (send t insert "Hello\n")
>
>> Lines?
>
> (send t insert "Hello\n")
> (send t insert "Goodbye\n")
>
>


Posted on the users mailing list.