On Mar 30, 10:22 pm, "William Stein" <[EMAIL PROTECTED]> wrote:
> On Sun, Mar 30, 2008 at 7:09 PM, Neal Holtz <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I've been playing a lot with interact recently -- I *really* like it.
> > While attempting to develop a step-at-a-time example of Newton-Raphson,
> > a couple of things came to mind.
>
> > 1. What do you think about a control that saves state between
> > interactions, but does not give you any visible control widgets?
> > I know you can save state using globals, but if this works without
> > too much trouble, it might be cleaner. In fact, I have an implementation
> > now that seems to work, that allows things like:
>
> > @interact
> > def _( a = save_state(i=0), b = ['Go'] ):
> > a.i += 1
> > print 'i=', a.i
>
> > 'a' does not appear as an interactive widget.
> > Every time you press 'Go' you get the next number.
>
> > Only minor testing do far, so I don't know about all the repercusions...
>
> > 2. What about a similar kind of thing, but gives you access to
> > all the controls, so perhaps your function could change
> > default values, reposition sliders, etc. Perhaps something
> > like
>
> > @interact
> > def _ ( f = sin(x), range=(0..20), controls=interact_controls() ):
> > ...
> > controls['range'].set_value(...)
>
> > The value of controls could be a dictionary indexed by variable name
> > ...
>
> > If this has any worth, I could attempt a proof-of-concept in a couple
> > of days.
>
> I think both of these are good ideas if they can be implemented
> robustly. The second will be harder to implement but be *extremely*
> useful in practice, I think. Probably somehow whenever the controls
> are changed via the second thing, we'll have to somehow know to
> redraw the entire output cell (including the input controls) in order to
> set the values of the controls appropriately. When I was writing
> funtool:http://wiki.sagemath.org/interact#head-16e9c0180afb4f04813e76ab5685ef...
>
> I could have done something much more powerful using something
> like your suggestion 2.
>
> William
>
> -- William
Ah yes -- I just took a crack at #2 and now realize its trickier than
first thought.
The controls are rendered to HTML only once, right, and not each time
the function is invoked. Oh well, learning my way around here. I'll
continue
worrying about it for a few days ...
My compliments on the code -- it was pretty easy to find my way
around.
neal
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---