# Dynamically updating interactive objects in Mathematica

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.

• 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

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]
]
}]
]


• 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