Thank you for the quick reply, Jason.
So if I understand your proposed solution, then in the following case,
you'll be able to specify that when any of the operations buttons is
clicked, BOTH sliders n1 and n2 will be read and sent to the server,
if the syntax is modified, and the checkbox, unless qualified with an
update, will behave as it currently does?
------------------- original ----------------------
@interact
def logarithmic_ops(
n1 = slider(1, 10, 0.5, 4.0, label='n1:'),
n2 = slider(1, 10, 0.5, 5.0, label='n2:'),
operation = ['Reset', 'Multiply', 'Divide'],
show_linear_ruler = checkbox(default=false, label='Show
linear ruler:')
):
------------ modified ----------------------
@interact
def logarithmic_ops(
n1 = slider(1, 10, 0.5, 4.0, label='n1:', update=False),
n2 = slider(1, 10, 0.5, 5.0, label='n2:', update=False),
operation = button(['Reset', 'Multiply', 'Divide'],
update=['n1', 'n2']),
show_linear_ruler = checkbox(default=false, label='Show
linear ruler:')
):
This approach could work, assuming that it will be applicable to ALL
other controls, not just button, like for example:
@interact
def point_setting(
n_points_i = input_box(default = 4, label = 'number of points:',
width = 5, update=False),
user_slope = input_box(default = 0, label = 'Your estimated
slope:', width = 5, update=False),
user_offset = input_box(default = 0, label = 'Your estimated
offset:', width = 5, update=['n_points_i', 'user_slope']),
show_calculations = checkbox(default = false, label = 'Show least
squares calculations:'),
show_best_fit = checkbox(default = false, label = 'Show best
fit:')
):
where only when user_offset is modified, does it grab the values of
n_points_i and user_slope and sends it to the server for evaluation.
Hope it makes sense, and definitely appreciate the effort!
HMark.
On Jul 1, 8:47 am, Jason Grout <[email protected]> wrote:
> On 7/1/11 10:08 AM, HMark wrote:
>
> > Hi,
>
> > I'd appreciate a pointer to how to resolve what seems to be a timing/
> > processing issue, where interact is triggered and is processing only
> > one event (namely the change in the input_box), and ignores another
> > (the click on the selector button).
> > '
>
> See commments below.
>
>
>
> > Thanks,
> > HMark.
>
> > On Jun 26, 6:16 pm, HMark<[email protected]> wrote:
> >> Hi,
>
> >> in the following simple interact function, the behavior I expect is:
> >> 1. user clicks on "New Question" and sees printed:
> >> in new. question = 0 answer= 0
> >> 2. user types 100 (as an example) into the input_box, and right after
> >> it clicks on "Check", and SHOULD see printed:
> >> in check. question= 1 answer= 100
>
> >> What I ACTUALLY get is:
> >> 1. user clicks on "New Question" and sees printed:
> >> in new. question = 0 answer= 0
> >> 2. user types 100 (as an example) into the input_box, and right after
> >> it clicks on "Check", and sees printed:
> >> in new. question = 1 answer= 100
>
> >> which seems to indicate that when a user types into the input_box, and
> >> doesn't do anything before clicking on the "Check" selector button,
> >> the "state" of the selector button doesn't change; only the state/
> >> value of the input_box changes (i.e. one change at a time?).
>
> >> I would expect that when I click on "Check", BOTH the value of the
> >> input_box, AND the state of the selector would change or be recognized
> >> by the system.
>
> >> Isn't this a bug?
>
> Yes. Sort of. It's a design issue. You are correct about your
> diagnosis. One way to get around this right now is to add an
> "auto_update=False" parameter to your function, which will add an
> "Update" button to your interact. Then all changes are saved until you
> press "Update" and then all changes are sent to the server.
>
> In fact, I'm very glad you reminded us about your post. Alex Kramer and
> I are rewriting interact functionality right now, and we just spent the
> last 30 minutes or so talking about design choices in updating output
> based on the controls. Your use-case led to us making a small tweak in
> our design to give you what you want. We're thinking of letting the
> user do something like:
>
> def _setting(
> operation = button(['Reset', 'New Question', 'Check'],
> update=['user_answer']),
> user_answer = input_box(default = 0, label = 'Your answer:', width
> = 25, update=False)
> ):
>
> which would mean that a click on the operation button would also get the
> user_answer value and send that, whereas just a change to the
> user_answer control would not send an update.
>
> Unfortunately, this rewrite probably won't be in Sage for at least
> another month, and probably won't be in for another 6 months maybe (it
> involves changing a lot of other Sage code to put into Sage). However,
> we have a simple server that will use this interact functionality, so it
> will be usable in some context in hopefully the next month.
>
> Thanks,
>
> Jason
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org