Wolfram Language & System 10.3 (2015)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.View current documentation (Version 11.2)

This feature is not supported on the Wolfram Cloud.

represents an object that displays as the dynamically updated current value of expr. If the displayed form of Dynamic[expr] is interactively changed or edited, an assignment is done to give expr the new value val that corresponds to the displayed form.

does not allow interactive changing or editing.

continually evaluates during interactive changing or editing of val.

also evaluates when interactive changing or editing is complete.

also evaluates when interactive changing or editing begins.

Details and OptionsDetails and Options

  • Dynamic[expr] can appear not only directly as an expression to display, but also for example as a coordinate in a graphics primitive or an object such as a slider, or as a setting for an option.
  • When used to assign values to expr through interactive operations, the expression in Dynamic[expr] will most often be a symbol x, an object , a part , or a list .
  • In graphics, for example, Point[Dynamic[{x,y}]] represents a point whose position is dynamically updated to be given by the current values of x and y. Whenever the point is interactively moved, assignments of the form are done. Point[Dynamic[{x,y}]] can be moved interactively; Dynamic[Point[{x,y}]] cannot.
  • Dynamic[expr] evaluates expr whenever it needs its value and it determines that any type of value of symbols on which it depends might have changed.
  • If Refresh or Clock objects appear in the evaluation of the expression in Dynamic[expr], then expr will always continually be reevaluated.
  • Dynamic has attribute HoldFirst, so that expr is not evaluated until its value is needed for display.
  • Dynamic[expr] is equivalent to Dynamic[expr,(expr=#)&].
  • Dynamic[expr,f] makes interactive operations not change expr except by virtue of the evaluation of .
  • Objects represented by Dynamic[expr,None] cannot be changed interactively, but will change if the value of expr changes for other reasons.
  • Dynamic[expr,Temporary] allows the displayed form of an object to change in the course of interactive operations, but assigns an updated value to expr only when the operations are complete.
  • For interactive mouse operations, Dynamic[expr,{fstart,f,fend}] typically evaluates once when the mouse is pressed, then evaluates whenever the mouse is moved, and then evaluates once when the mouse is released.
  • If the mouse is not moved, , f, and are each evaluated exactly once.
  • is always evaluated once immediately after the evaluation of , and when it is last evaluated, the value of val is always the same as in .
  • Interactive operations that can affect Dynamic objects include dragging of elements in graphics or in objects such as Slider, as well as editing of fields in objects such as InputField.
  • The functions , f, and can be the following:
  • Automaticassign values using Set
    Noneperform no action
    Temporaryallow interactive operations to make temporary changes
  • Dynamic[expr,f] is equivalent to Dynamic[expr,{None,f,None}].
  • Dynamic[expr,Temporary] is equivalent to Dynamic[expr,{None,Temporary,Automatic}].
  • Dynamic[expr,f] can be used to enforce constraints on values assigned to expr.
  • Dynamic[expr,f] can be used to do assignments for individual variables when expr is an expression like .
  • A function should have attribute HoldRest if it is going to perform an assignment to expr. This can be achieved with Function[{v,e},body,HoldRest].
  • The following options can be given:
  • BaseStyle{}base style specifications for the displayed object
    DeinitializationNonean expression to evaluate when the Dynamic can no longer be displayed
    EvaluatorAutomaticthe kernel to use for evaluations
    InitializationNonean expression to evaluate when the Dynamic is first displayed
    ShrinkingDelay0.how long to delay before shrinking if the displayed object gets smaller
    SynchronousUpdatingTruewhether to evaluate contents synchronously
    TrackedSymbolsAllsymbols whose changes trigger an update
    UpdateIntervalInfinitytime interval at which to do updates
  • Dynamic[e] displays as the dynamically updated current value of e in StandardForm and TraditionalForm, but just as Dynamic[e] in InputForm and OutputForm.
  • Dynamic[expr] provides an analog of delayed assignment, where values are implicitly requested by the need to display, rather than by evaluation of an expression.
Introduced in 2007