Hi,

I have started using sage a short while ago, after playing with
Mathematica for a while, and I'm impressed!

One thing I'm missing is a way to change interact widget rendering in
the browser, from within the code.

So, in the simple example at http://www.sagenb.org/home/pub/2409/ (and
also below), what I'd like to see is that the n_points_local input_box
widget (in this case, but other types of widgets in general) gets
updated every time a new point is added, and n_points_global and
n_points_local get modified.

Similarly, the code changes the state of the point_operation buttons
to 'Reset' after every time a point is added, but the button widgets
rendering doesn't reflect that.

1. is there a way to do this with the built-in functionality, or do I
need to build a custom GUI with widgets rendered outside of @interact
(but within the browser)?

2. Regardless, are there examples of custom GUIs, rendered in the
browser (Notebook), interacting with the sage functionality, I can
look at?

Any pointers would be appreciated.


# --- global ---
display_points = Graphics()
n_points_global = 5

for i in range(n_points_global):
    display_points += point((round(10 * random(), 0), round(10 *
random(), 0)))

@interact
def point_setting(
        point_operation = ['Reset', 'Add a point'],
        n_points_local = input_box(default = n_points_global, label =
'number of points:', width = 5)
    ):
    global display_points, n_points_global

    if point_operation == 'Add a point':
        display_points += point((round(10 * random(), 0), round(10 *
random(), 0)))
        n_points_global += 1
        n_points_local = n_points_global
        point_operation = 'Reset'

    print "number of points = ", len(display_points)
    show(display_points, xmin = 0, xmax = 10, ymin = 0, ymax = 10)

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to