[plt-scheme] Re: GUI
On Jan 7, 2010, at 1:42 PM, Avi wrote:
> Is there a way to compare what is entered into a text-field using a
> conditional?
>
>
Of course.
> if x is equal to what is in text box a than run program b
Yeap.
>
>
>
> On Jan 6, 10:22 pm, Matthias Felleisen <matth... at ccs.neu.edu> wrote:
>> (require htdp/gui)
>>
>> (define w
>> (create-window
>> (list
>> (list
>> (make-button "go"
>> (lambda (e)
>> (begin
>> (hide-window w)
>> (local ((define w
>> (create-window
>> (list (list (make-button
>> "stop" (lambda (e) (hide-window w))))))))
>> true))))))))
>>
>> On Jan 6, 2010, at 6:18 PM, Avi wrote:
>>
>>
>>
>>> 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
>>> _________________________________________________
>>> 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