Hot answers tagged dynamic
8
My take:
toward[p1_, p2_, v_: .05] := p1 + v Normalize[p2 - p1];
{n, r} = {4, 3};
DynamicModule[{pts, history},
pts = r {Cos[#], Sin[#]} & /@ Range[2 Pi/n, 2 Pi, 2 Pi/n];
history = {pts};
Print[Dynamic[ListPlot[Transpose@history,
AspectRatio -> Automatic, Joined -> True,
PlotStyle -> Directive[Thick, CapForm["Round"]],
...
6
[Edit 2: I've added further analysis and modified some of the explanations, esp. with respect to Refresh. Still far from complete, I fear.]
First of all, I find if I set SetSystemOptions["DynamicUpdateInterval" -> 0.005], then I cannot perceive a difference in performance with or without the Animator running. I see a very few hiccups in both scenarios, ...
6
I found two choices. One is to use the option UpdateInterval -> 0 to force the update being done as fast as possible. The second is to change Disk[{Dynamic[bla], 0}, 1, Dynamic[bla]] in pacman definition to Dynamic[Disk[{bla, 0}, 4, bla]] seems to make it smoother on my Mathematica 9. I guess, maybe when multiple Dynamics are used, they compete against ...
4
Try
Column[
{Row[{InputField[Dynamic[x]], InputField[Dynamic[y]]}],
RadioButtonBar[
Dynamic[op], {Times -> "Multiply Numbers",
Plus -> "Add Numbers"}],
Dynamic@op[x, y]
}
]
Notice how code and data are the same thing in Mathematica, so I can use the fact that the operators Plus and Times can be stored in variables to construct the ...
3
Perhaps something along these lines could help?
$PrePrint= # /.
Except[Null] :> With[{line = $Line}, DynamicSetting@Dynamic@In[line]] /.
DownValues[In] &;
After running this, everything you evaluate is automatically wrapped in Dynamic so its value is updated automatically. I haven't tested it much so there may be issues.
(Be careful ...
2
Perhaps this is what you want:
data = Range[1, 100];
Column[{
Slider[Dynamic[n], {0, 10000000, 1}],
Pane[
TableForm /@ Dynamic[n + data],
ImageSize -> {200, 200},
Scrollbars -> True]}]
Update
Perhaps this is what you're seeking:
data = Range[1, 1000];
Row[{
Column[
{Slider[Dynamic[m], {0, 10000000, 1}],
Pane[TableForm /@ ...
2
I've also noticed this bug, although buttons/drop down menus do continue to work, for me only sliders become unresponsive after suspend (Ubuntu 12.10/Mathematica 9.0.0.0 x86 64 bits).
A possible workaround is thus to change all parameter controls to buttons/dropdown menus by providing a finite list of values the parameter is allowed to take:
...
2
You can use the second argument to Dynamic:
DynamicModule[{fValues, msg, processChanges},
fValues = {Null, Null, Null, Null};
msg = "No change yet";
processChanges[field_, oldvalue_, newvalue_] :=
msg = Row[{field, " was changed from ", oldvalue, " to ", newvalue}];
{Table[With[{i = i}, (InputField[
Dynamic[Part[fValues, i], processChanges[i, ...
2
Often I do something kludgy like
Dynamic[foo; data]
<<"filepath.mx"; foo++
It's somewhat similar to Albert Retey's first solution. However, foo is a global variable and data can be an arbitrary piece of code.
Here's a way to dress it up. It does the same thing, but it reads better.
ClearAll[dependsOn, update];
SetAttributes[dependsOn, HoldAll];
...
2
I have no insight into the internals but have found several situations where for whatever reasons the automatic determination of the necissity to update fails. I would wish there would be a programmatic possibility to tell Mathematica that a ceratin symbol has changed, but don't know about that. Of course you could do something stupid like this to inforce an ...
2
Seems no holdon, but to achive the same effect is easy too. Add a Joined->True, looks like a joined curve now
Clear["`*"];
forward[{x1_,y1_},{x2_,y2_},v_: 5]:=Block[{alpha},alpha=Switch[Sign[x1-x2],-1,ArcTan[(y2-y1)/(x2-x1)],1,Pi+ArcTan[(y2-y1)/(x2-x1)],0,Pi/2,_,-Pi/2];{x1+v 0.01 Cos[alpha],y1+v 0.01 Sin[alpha]}];
list={};
...
1
I'm not sure if this fully answers your question, but here is a method of using the Dynamic to check if a dialog is already open and reopen it if it has been closed:
DynamicModule[{nb = CreateDialog[Dynamic@y]},
TogglerBar[
Dynamic[y, (y = #;If[Not@MemberQ[Notebooks[], nb],nb = CreateDialog[Dynamic@y]]) &],
Range[5]]]
1
Here's a guess at what you're after:
SeedRandom[1];
data = Accumulate[RandomReal[{-0.2, 0.2}, 300]];
thirds = Partition[data, 100];
interps = Interpolation /@ thirds;
myplot = ListLogLinearPlot[thirds];
DynamicModule[{pos = MapThread[{Log@#, #2[#]} &, {{5, 16, 50}, interps}]},
LocatorPane[
Dynamic[pos,
(pos = MapThread[
Function[{pt, ...
1
A rough straightforward implementation is to find all of the subpaths in your path, and generate a button that allows setting a new path at that level for each such subpath. Here's an implementation that generates the list of files/folders when you press the menu to ensure it's up to date.
pathParts[path_] := ...
1
My solution is only prototype but I'll update it later. It differs from Yours approach becouse my function is blind. A priori it does not know the structure of file's tree.
And there is also ActionMenu not PopupMenu. :(
This version is not very elegant but I'm going to improve this.
Lets start and set main directory and create function for each menu:
dir ...
Only top voted, non community-wiki answers of a minimum length are eligible
