[plt-scheme] Re: GUI

From: Avi (n4alpaca at gmail.com)
Date: Wed Jan 6 18:18:02 EST 2010

Please disregard my last few statements, I have decided to change my
code based on the revisions that matthias gave me, but I have run into
a new problem, I want to have certain gui windows open other gui
windows, but they all open at once, also I would like to know how to
make a function run when certain text is put into a text box.
-Thanks

On Jan 6, 3:37 pm, Matthias Felleisen <matth... at ccs.neu.edu> wrote:
> After fixing numerous syntactic mistakes (in a nonsensical but  
> grammatically correct way), the two windows pop up just fine:
>
> ;; Intermediate plus Lambda
>
> (require htdp/gui)
>
> (define a-text-choices
>      (make-message "Please pick what you want to do."))
> (define options
>   (list "Compound""Moles(experimental)"))
> (define choices (make-choice options))
>
> (define b-text-field
>      (make-text "Please input number of elements"))
>
> (define (choose-prog x)
>   (cond
>     [(symbol=? 2 (text-contents b-text-field)) "Molecule2"]
>     [(symbol=? 3 (text-contents b-text-field)) "Molecule3"]
>     [(symbol=? 4 (text-contents b-text-field)) "Molecule4"]))
>
> (define Element-Window
>    (create-window
>         (list (list b-text-field)
>               (list (make-button "Go" ; choose-prog
>                                  (lambda(e) (hide-window Element-
> Window)))))))
>
> (define (choose x)
>   (cond
>     [(symbol=? 0 (choice-index choices))Element-Window]))
>
> (create-window (list (list a-text-choices)(list choices) (list (make-
> button "OK" choose))))
>
> ;; ---
>
> Since I don't know what you want to achieve, I can't help much more. I  
> can tell you, though, that you should design individual functions with  
> check-expect tests and examples and so on.
>
> Good luck -- Matthias
>
> On Jan 5, 2010, at 7:28 PM, Avi wrote:
>
>
>
> > I have a program which (perhaps I should add that I began scheme 2
> > months ago) gives me the following error:
>
> > reference to an identifier before its definition: choose-prog <----
> > This is a definition
>
> > I know how to fix this error, but when I move my GUI file above this
> > definition, it will give me another error that tells me  that I can
> > not use a program before I define it. A runs B, but B takes data from
> > A so B must come after A, but A also must go after B because of the
> > manner in which the scheme compiler works. Please help me resolve. If
> > I did not do a good enough job explaining, try it for yourself with
> > this code (this is the code i'm having trouble with).
>
> > (define a-text-choices
> >     (make-message "Please pick what you want to do."))
> > (define options
> >  (list "Compound""Moles(experimental)"))
> > (define choices
> >  (make-choice options)
> > (define b-text-field
> >     (make-text "Please input number of elements"))
>
> > (define choose-prog
> >  (cond
> >    [(symbol=? 2 (text-contents b-text-field)) Molecule2]
> >    [(symbol=? 3 (text-contents b-text-field)) Molecule3]
> >    [(symbol=? 4 (text-contents b-text-field)) Molecule4]))
>
> > (define Element-Window
> >   (create-window
> >        (list (list b-text-field)(list (make-button "Go" choose-prog
> > (lambda(e)(hide-window Element-Window)))))))
>
> > (define choose
> >  (cond
> >    [(symbol=? 0 (choice-index choices))Element-Window]))
>
> > (create-window
> >        (list(list a-text-choices)(list choices)(make-button "OK"
> > choose)))
>
> > _________________________________________________
> >  For list-related administrative tasks:
> >  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> _________________________________________________
>   For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme


Posted on the users mailing list.