[plt-scheme] Using FrTime

From: Gregory Cooper (greg at cs.brown.edu)
Date: Sun Oct 1 17:52:55 EDT 2006

If you want to get the slider's time-varying behavior, you need

(define duration (send slider get-value-b))

instead of

(define duration (send slider get-value))

However, there seems to be a bug in the current svn version that makes
this value 0 until you actually move the slider.  (Dan, do you have a
fix for this?  Perhaps you gave me an update and I never committed
it...)  Until we commit a fix, you can say something like:

(define duration (max (send slider get-value) (send slider get-value-b)))

to get the correct initial value.

Greg

On 10/1/06, Jon Rafkind <workmin at ccs.neu.edu> wrote:
> I got a little farther but the slider in the example doesn't update the
> gauge.
>
> (require (lib "class.ss"))
> (require (lib "fred.ss" "frtime/demos/gui"))
>
> (define frame (new ft-frame% (label "Timer") (width 200) (height 80)
> (shown #t)))
> (define slider (new ft-slider% (parent frame) (label "Duration")
> (min-value 5) (max-value 60)))
> (define button (new ft-button% (parent frame) (label "Reset")))
> (define duration (send slider get-value))
> (define last-click-time (hold (map-e (lambda (_) (value-now seconds))
>                                      (send button get-value-e))
>                                      (value-now seconds)))
>
> (define elapsed (min duration (- seconds last-click-time)))
> (define gauge (new ft-gauge% (label "Elapsed Time") (range duration)
>                    (stretchable-width #t)
>                    (parent frame) (value elapsed)))
> (define message (new ft-message% (label (format "~a s" elapsed))
>                      (parent frame) (min-width 50)))
>
> Also I updated (send button get-clicks) to be (send button get-value-e).
> There doesn't seem to be any significant difference between 'duration'
> than 'elapsed' yet the label in the 'message' is updated every second
> but the gauge does not update when I move the slider around.
>
> Jon Rafkind wrote:
> > Oh you are right, I copied the line wrong. I changed it to this
> >
> > (define frame (new ft-frame% (label "Timer") (width 200) (height 80)
> > (shown #t)))
> >
> > And it works. Thanks.
> >
> > Gregory Cooper wrote:
> >
> >> It should be "label", not "label%", as for ordinary MrEd widgets (if
> >> the paper says "label%", it's a typo).  And it needs to be "shown"
> >> instead of "visible".  (Sorry for the discrepancy.)
> >>
> >> On 10/1/06, Jon Rafkind <workmin at ccs.neu.edu> wrote:
> >>
> >>> If I require class.ss and fred.ss I get this error
> >>>
> >>> instantiate: unused initialization arguments: (label% "Timer") (visible
> >>> #t) for instantiated class: .../aux-mixin-macros.ss:19:16
> >>>
> >>> Where my only line of code( other than the require's ) is
> >>>
> >>> (define frame (new ft-frame% (label% "Timer") (width 200) (height 80)
> >>> (visible #t)))
> >>>
> >>> Gregory Cooper wrote:
> >>>
> >>>> Hi Jon,
> >>>>
> >>>> As you've noticed, class.ss and fred.ss have to be explicitly required
> >>>> before you can use the widget set.  However, once you've done so, they
> >>>> should all work.  What errors do you get?  Do they happen on
> >>>> "require", or when attempting to evaluate something?
> >>>>
> >>>> Greg
> >>>>
> >>>> On 10/1/06, Jon Rafkind <workmin at ccs.neu.edu> wrote:
> >>>>
> >>>>> Im reading "Crossing State Lines: Adapting Object-Oriented
> >>>>>
> >>> Frameworks to
> >>>
> >>>>> Functional Reactive Languages" by Ignatoff, Cooper, and Krishnamurthi
> >>>>> and would like to try out the first example but can't get it
> >>>>>
> >>> working in
> >>>
> >>>>> drscheme 352. I chose the FrTime language and typed this line into
> >>>>>
> >>> the
> >>>
> >>>>> definitions windows:
> >>>>>
> >>>>>    (define frame (new ft-frame% (label% "Timer") (width 200)
> >>>>>
> >>> (height 80)
> >>>
> >>>>> (visible #t)))
> >>>>>
> >>>>> Verbatim from the paper( except the paper used 'true' instead of
> >>>>>
> >>> #t ).
> >>>
> >>>>> This led to the error:
> >>>>>    reference to undefined identifier: new
> >>>>>
> >>>>> So I did
> >>>>>    (require (lib "class.ss"))
> >>>>> But then got a different error:
> >>>>>
> >>>>>    reference to undefined identifier: ft-frame%
> >>>>>
> >>>>> Grepping through collects/frtime I found ft-frame% defined in
> >>>>> frtime/demos/gui/fred.ss.
> >>>>>
> >>>>>   ~/tmp/src/drscheme-352/collects/frtime $ grep -r "ft-frame" *
> >>>>>   demos/gui/demo/bindec.ss:(current-widget-parent (new ft-frame%
> >>>>>
> >>> (label
> >>>
> >>>>> "Binary<-->Decimal")))
> >>>>>   demos/gui/demo/timer.ss:(current-widget-parent (new ft-frame%
> >>>>>
> >>> (width
> >>>
> >>>>> 400) (stretchable-width #t)))
> >>>>>   demos/gui/fred.ss:  (define ft-frame%
> >>>>>   demos/gui/simple.ss:          (set! fr (new ft-frame%)))
> >>>>>
> >>>>> If I require 'fred.ss' I get a bunch more errors which probably
> >>>>>
> >>> aren't
> >>>
> >>>>> worth going into. Am I missing something?
> >>>>> _________________________________________________
> >>>>>   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
> >
> >
> >
>


Posted on the users mailing list.