New answers tagged

3

Use the second argument to Dynamic. Example: DynamicModule[{NumSelec = {}}, Column[{ CheckboxBar[ Dynamic[NumSelec, (If[Length[#] > 2, NumSelec = #[[-2 ;;]], NumSelec = #]) &], {1, 2, 3, 4}], Dynamic[NumSelec] }] ]


1

Here's a way using a function to rewrite the dynamic value when length of 2 is exceeded. Manipulate[ NumSelec = limit[NumSelec, 2], {NumSelec, {1, 2, 3, 4}, ControlType -> CheckboxBar}, Initialization :> ( limit[x_, num_] := If[ListQ[x], If[Length[x] > num, x[[-num ;;]], x], x]) ]


1

This is one way using DynamicModule DynamicModule[{NumSelec1 = {}, NumSelec2 = {}, NumSelec3 = {}, false}, Column[{ Dynamic@ Row[{CheckboxBar[Dynamic[NumSelec1], {1}, Enabled -> (NumSelec1 =!= {} || false)], CheckboxBar[Dynamic[NumSelec2], {2}, Enabled -> (NumSelec2 =!= {} || false)], ...


1

Changing initial conditions can be accomplished in the same way that parameters are changed. For instance, replace Yb[0] == 0.1 by Yb[0] == Yb0, add the corresponding control, {{Yb0, 0.1}, 0, 1, Appearance -> "Labeled"}, and include Yb0 in the list of TrackedSymbols.


4

Responding to the OP's comment, here is a way to monitor subkernel progress. (* Clear variables *) ToExpression["x" <> ToString[#], StandardForm, Clear] & /@ ParallelEvaluate[$KernelID, Kernels[]]; (* Monitor *) With[{varnames = "x" <> ToString[#] & /@ ParallelEvaluate[$KernelID, Kernels[]]}, With[{vars = ToExpression@varnames}, ...


4

This should do what you are asking about, ParallelEvaluate[x = 0; {$KernelID, With[{x = x}, Dynamic[x]]}] (*{{1,0},{2,0},{3,0},{4,0}}*) But it negates the point of having Dynamic since it won't update. Need to see the full code to see how you want to use it in the end.


3

Just returning to this question now and after reading your addendum I don't think you have adequately set up your test. For example here we see that when the kernel stops the value of a is not preserved and you get error boxes appearing: If you want a to be Global then try this: Dynamic@If[ListQ[a] &&Length[a]>1&& TrueQ[a[[1]] > 0], ...


6

You can use the SaveDefinitions option of DynamicModule for this: DynamicModule[{}, Dynamic@a[[2]], SaveDefinitions -> True]


3

To start your notebook with Dynamic Updating Enabled not being checked add this code to your notebook: Dynamic[, Initialization :> FrontEndExecute[FrontEndToken["ToggleDynamicUpdating"]]] To return the dynamic updating back, you should use ToggleDynamicUpdating again, as you correctly mentioned in the comments: ...


3

This is more or less directly cribbed from the help: Manipulate[Graphics[{color, Polygon[CirclePoints[sides]]}], {{sides, 3,"Number of Sides"}, 3, 17, 1}, {color, Green}]


3

I believe this is the natural and idiomatic way to do it: Manipulate[Graphics[{colour, Polygon[CirclePoints[sides]]}], {sides, 3, 17, 1}, {{colour, Orange}, {Green -> "Green", Orange -> "Orange"}} ]


3

TabView is for viewing. You can associate color changes with the second argument of TabView but it will be easier to just use what is designed for that, like SetterBar. Moreover, the less inside Dynamic the better so instead of creating whole Graphics you can just tell the FrontEnd to take care of that colour and Polygon. DynamicModule[{p = 3, colour = ...


1

Algohi's post answers the above question while adhering to the OP's code very closely. I suggest abandoning such adherence for two reasons. Simpler code. Better localization of variables. Here is what I get by taking Algohi's work as a basis, but simplifying it without worrying about maintaining the structure of the OP's code: DynamicModule[{locators, ...


2

Something like this? DynamicModule[ {point1 = {4, 4}, point2 = {4.5, 4.5}, point3 = {5, 5}, point4 = {6, 6}, point5 = {6.5, 6.5}}, dataset = {point1, point2, point3, point4, point5}; p1 = LocatorPane[ Dynamic[dataset], Dynamic[ListPlot[dataset, PlotRange -> {{0, 10}, {0, 10}}]]]]; GraphicsRow[ {p1, Dynamic[ ...



Top 50 recent answers are included