[racket] Help with racket/gui and framework

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Tue Feb 4 08:41:55 EST 2014

I think you want this for main-frame:

(define main-frame (new frame:text%))

But for the other, it looks not so simple. The framework isn't abstracted
out in the right ways to have two different lists of recently opened files.
It probably should be, tho. Patches welcome! :)

Robby


On Tue, Feb 4, 2014 at 1:25 AM, Harry Spier <vasishtha.spier at gmail.com>wrote:

> A clarification about point 1 below:  If I open a file or select "new" in
> the file menu it creates a new window and I'm able to save the text from
> that new window.  Its just when I run the program and type text into the
> visible frame of the original window that there are no "save","save
> as","print" etc. menu items in the file menu.
>
> Thanks,
> Harry
>
>
> On Mon, Feb 3, 2014 at 11:00 PM, Harry Spier <vasishtha.spier at gmail.com>wrote:
>
>> I'm building a small text editing application based around an editor
>> built with racket/gui and framework..  The idea is that it has the usual
>> text editing features but also buttons where I select text and then based
>> on which button I click on the selected text is manipulated in different
>> ways.  I'm just building the gui part now.  I started using just racket/gui
>> but then tried to implement some things in "framework" but I'm having
>> trouble with a few things and I can't figure out how to do them from the
>> documentation.
>>
>> In the code below:
>> 1) How do I add a "Save" feature to the file menu.
>> 2) The "Open recent" menu item in the file menu opens my DrRacket
>> "recently opened files".  How do I get it to look at its own history
>> instead of DrRackets.
>> 3) Where I define main-frame as a frame:standard-menus% object in the
>> code below, I tried to define it as a frame:editor% object but I couldn't
>> get that to work.  Could someone show me how to do that.
>>
>> Thanks,
>> Harry
>> -------------------------------------
>> #lang racket/gui
>> (require framework)
>> (application:current-app-name "Sanskrit editor")
>>
>> (define main-frame (new frame:standard-menus% [label "Sanskrit editor"]))
>>
>> (send main-frame show #t)
>> (define main-area (send main-frame get-area-container))
>> (define h-panel (new horizontal-panel% [parent
>> main-area][stretchable-height #f]))
>> (define msg (new message% [parent main-area][label "NO EVENTS SO FAR...
>> "]))
>> (define button-font (make-object font% 12 "Consolas" 'default 'normal
>> 'bold ))
>> (define button-1 (new button% [parent h-panel][font button-font]
>>     [label "Apply Sandhi"]
>>     ; Callback procedure for a button click:
>>     [callback (lambda (button event)
>>            (send msg set-label "TEST Apply Sandhi Test"))]))
>>
>> (define button-2 (new button% [parent h-panel][font button-font]
>>     [label "HK-->Unicode"]
>>     ; [style '(border)]
>>     ; Callback procedure for a button click:
>>     [callback (lambda (button event)
>>            (send msg set-label "TEST Converted HK-->Unicode"))]))
>>
>>
>> (define main-text-editor (new text%))
>>
>> (define default-delta (make-object style-delta%) )
>> (send default-delta set-delta-face "Consolas")
>> (send default-delta set-size-add 4)
>> (send main-text-editor change-style default-delta)
>> (send main-text-editor set-max-undo-history 400)
>> (send main-text-editor auto-wrap #t)
>>
>> (define main-canvas (new editor-canvas% [parent main-area]))
>> (define WhiteSmokeColor (send the-color-database find-color "WhiteSmoke"))
>> (send main-canvas set-canvas-background WhiteSmokeColor)
>> (send main-canvas set-editor main-text-editor)
>>
>> --------------------------------------------------
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> .
>>
>>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140204/4c5df4d4/attachment-0001.html>

Posted on the users mailing list.