Ask Your Question

interact buttons that do stuff, not just selectors

asked 2013-12-06 18:15:52 +0200

Tom Burke gravatar image

updated 2013-12-06 20:09:55 +0200

Is there some way to build a interact control button so that, when pressed, a designated action/program is carried out so as to produce a new result to be added to an existing display -- e.g., a button to generate a new random number and add it to an existing list, a button to add another data point to an existing scatter plot, or to eliminate an outlier, etc. An example that I could look at would be enough to get me started.

FWIW, this is what the "Button" gizmo in Mathematica does: "Button[_label_,_action_] represents a button that is labeled with _label_, and evaluates _action_ whenever it is clicked."

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2014-08-14 19:21:17 +0200

ndomes gravatar image

An example what you can do to get something like an action button:

status = False

def toggle():
    global status
    status = not status

def _(action=[toggle]):
    print status

A second example ( putting 'random_number' as string in the selector list creates a labeled button)

def random_number():
    return random()

def _(action=selector(['random_number'],buttons=True)):
    action = eval(action) 
    print action()
edit flag offensive delete link more

answered 2013-12-06 22:01:54 +0200

kcrisman gravatar image

This isn't currently possible in the sagenb version of interacts, but I believe something like this can be done in the Sage cell version.

edit flag offensive delete link more


Can you point me to an example?

Tom Burke gravatar imageTom Burke ( 2013-12-12 08:33:55 +0200 )edit

Not right now - they aren't well advertised, and I didn't save the examples I had, unfortunately. and are two places that might include them. The lead developer of the Sage cell would have lots but I think he is too busy to read this forum right now :)

kcrisman gravatar imagekcrisman ( 2013-12-12 15:56:12 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2013-12-06 18:15:52 +0200

Seen: 819 times

Last updated: Aug 14 '14