Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Is it possible to create interactive code in Mathematica (via EventHandler[] or Manipulate[] perhaps) that continually updates some calculation based on external data in the time when no user input is received?

As a trivial example, code that shows the current time, with seconds, continually updating, and which allows the user to click on any of the numbers to change their color.

Thank you.

share|improve this question
    
Michael when you refer to "external data in the time when no user input is received" could you mean scheduling an import of data from an external source at either a fixed time or regular intervals? –  Mike Honeychurch Dec 28 '12 at 1:23
    
Also have a look at Clock in the documentation. In fact, this question is quite unspecific. For example, do you want the updates to continue when the relevant cell is not being displayed on the screen? Dynamic doesn't permit that. What is it you're trying to achieve? What have you tried? –  Jens Dec 28 '12 at 5:16
    
Responding to the first comment above -- yes, in practice, this will involve a scheduled import of third party data (actually, essentially continuous import of data that changes very frequently). –  Michael Stern Dec 28 '12 at 13:04

1 Answer 1

up vote 6 down vote accepted

Yes, it is possible. Have you read the tutorials about Dynamic? Here is a simple example of a continuously updated time which changes color on Mouseover

Dynamic[Refresh[
  Mouseover[DateString[],Style[DateString[],20,Blue]],
UpdateInterval->1]]

Here the slightly more complex example with two buttons.

DynamicModule[{bold=False,blue=False},
  Column[{
    Button["Toggle Bold",bold=!bold],
    Button["Toogle Blue", blue=!blue],
    Dynamic[Refresh[
      Style[DateString[],If[blue,Blue,Black],If[bold,Bold,Plain]],UpdateInterval->1]
    ]
  }]
]

Mathematica graphics

share|improve this answer
    
That is helpful. Can you show how to do it with buttons above the time, each representing a different action (say, a different color to change to time to when clicked?) –  Michael Stern Dec 28 '12 at 0:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.