Tag Info

New answers tagged

2

DynamicEvaluationTimeout and Style may be used to locally set the dynamic timeout bound: DynamicModule[{a = "start"}, Style[{ Button["does time out", Pause[6]; a = "end"], Dynamic[a]}, DynamicEvaluationTimeout -> 10]]


1

The Table approach: data = {{66, 55, 3}, {44, 33, 2}, {22, 11, 1}}; Grid[{{Style["direction North", Bold]}}~Join~ Table[{Style["traffic path", Bold], i, Labeled[InputField[Dynamic[data[[#, 1]]] &@i, FieldSize -> 10], "Q", Left, LabelStyle -> Directive[Bold]], Labeled[InputField[Dynamic[data[[#, 2]]] ...


1

Try this: data = {{66, 55, 3}, {44, 33, 2}, {22, 11, 1}}; MapIndexed[(d[First[#2]] = #[[1]]) &, data]; MapIndexed[(e[First[#2]] = #[[2]]) &, data]; MapIndexed[(f[First[#2]] = #[[3]]) &, data]; Grid[Prepend[Map[Function[i, {Style["traffic path", Bold], i, Labeled[InputField[Dynamic[d[i], (d[i] = data[[i, 1]] = #) &], ...


2

One possibility is to use MapIndexed: n = 3; dyn = Table[False, {i, n}]; A = Dynamic@Transpose[{Range[n], dyn}] MapIndexed[Checkbox[Dynamic[dyn[[#2[[1]]]]]] &, Range[n]]


2

Compare the output of this: Table[ Dynamic[i], {i,3}] (* gives {i,i,i} *) with this: Table[ With[{i=i},Dynamic[i]], {i,3}] (* gives {1,2,3} *) Now you can use that: a = Range[3]; Table[ With[{i=i}, Dynamic[ a[[i]] ] ], {i,3}] (* gives {1,2,3} *) Then: a+=1; (* changes output above to {2,3,4} *) Addendum to address question in the comments ...


6

Body of Manipulate is wrapped by Dynamic and Dynamic doesn't know what's inside inner Dynamics, that's how we can screen a variable to not prompt the very outer Dynamic to evaluate: Manipulate[ e = RandomVariate[NormalDistribution[0, sigma], n]; {Dynamic@a, e}, {{n, 3}, 1, 5, 1, Appearance -> "Labeled"}, {{sigma, 1}, 1, 2, Appearance -> ...


1

Moving it to a Manipulate sounds like a better idea: Manipulate[ makes = Import[ StringJoin[ "http://www.fueleconomy.gov/ws/rest/vehicle/menu/make?year=", ToString@year], "XML"]; Row[{"Loaded car makes for the year ", Style[ToString[year], {FontFamily -> "Arial", Large, Red}]}], {year, Reverse@years} ]


3

After commenters and answerers pushed me to investigate TaggingRules rather than DynamicModule as a strategy, I've worked out a solution. After the fact, it's actually embarrassingly simple. In the package that supports this notebook (or, equivalently, in notebook initialization cells), I define helper functions: SetAttributes[getCounter,Listable]; ...


6

Reanalysis My earlier assertions were incorrect or at least incomplete. I now believe the problem in your code originates because of a particular behavior that can be seen in this separate example: asc = <|foo -> <|bar -> <|baz -> 1|>|>|> <|foo -> <|bar -> <|baz -> 1|>|>|> asc[foo][bar][baz] = 2; ...


2

You can use what I call the "module trick" to bind a local variable to the association returned by speaker["settings"], this reduces your problem to the previously solved one and works. Module[{u = speaker["settings"]}, AdjustSettings[u]]


1

Some useful information are in this post from Szabolcs, however your question is a little different. Indeed, actually you only need to save an information (the counter value) inside a notebook and preserve it across frontend sessions. For such cases TaggingRules seems to be the best solution. DynamicModule could eventually be another option to save ...


2

You need to say that you want to recalculate heatPARKsensible or define it with SetDelayed so Dynamic can take care of it: DynamicModule[{FlowratePARK = 100, TemperaturePARK = 350, heatPARKsensible, heatbalance} , heatbalance = {{ Button["Primary Air", CreateDialog[ Column[{Row[{Style["Flow rate(kg/hr)", Bold, 14], ...


19

Presumably your Notebooks are not being saved in a Trusted Path. Start by reading the tutorial Notebook Security, and note: If the notebook's directory is trusted, the notebook will be allowed to automatically perform dynamic evaluations without alerting the user. If the notebook's directory is untrusted, the user will be alerted upon any attempt by the ...


1

I think it's easier to create the counting clock by using Refresh without Clock: Manipulate[Graphics[{color, Rectangle[{-1, -1}/2, {1, 1}/2], White, Rectangle[{-1, -1}/4, {1, 1}/4], If[color === White, White, Black], Dynamic[Refresh[Text[If[Round[AbsoluteTime[] - refTime] > 30, refTime = AbsoluteTime[]]; Round[AbsoluteTime[] - ...


2

You can insert your Manipulate[...] in a DynamicModule[{lower,upper},...]: DynamicModule[{lower, upper}, Manipulate[ Refresh[ lower = distPlotRange[distribution, -1, 4]; upper = distPlotRange[distribution, 1, 4]; fillRange = {Max[#[[1]]], Min[#[[2]]]} &[ Transpose[{fillRange, {lower, upper}}]];, TrackedSymbols :> {distribution} ...


2

One can localize the scope of variables to Manipulate by adding them as arguments to Manipulate with ControlType None. For your case Manipulate[Refresh[lower = distPlotRange[distribution, -1, 4]; upper = distPlotRange[distribution, 1, 4]; fillRange = {Max[#[[1]]], Min[#[[2]]]} &[ Transpose[{fillRange, {lower, upper}}]];, TrackedSymbols :> ...


3

One can use $Pre to check if an input expression defines the correct variable and is doing so using the correct value. SetAttributes[check, HoldAll] check[new_Set] := (Print["You guessed it!"]; new) /; HoldForm@new == HoldForm@Set[foo, 23] check[new_Set] := (Print[ "You've guessed the right variable name, but not the right value yet."]; new) /; ...


4

Something, that more or less does what you asked for, can be achieved by creating a hidden InitializationCell using a DynamicWrapper DynamicWrapper["xxx", If[foo == 23, MessageDialog["You guessed it!"], MessageDialog["You've guessed the right variable name, but not the right value yet."]]]



Top 50 recent answers are included