Tag Info

New answers tagged

2

Edit I've updated my answer entirely since the updated question First Issue As detailed in the documentation for Initialization, this expression is not evaluated until after the content of the DynamicModule has been evaluated and not until "the construct is first displayed". This requires that any Initialization variable must be wrapped in Dynamic to be ...


5

Version 10.1 now supports the Method->"Queued" option for EventHandler. Unfortunately, I forgot to document that fact (sorry!). Documentation updated now for future releases. Also, your code could be improved by making a progress indicator that doesn't do kernel evaluations. This progress indicator just runs in the FE and won't get any hiccups from ...


1

There are some other interesting aspects with this strange behaviour observed by Kuba. LinkSnooper shows a bit more. When the option UpdateInterval is used in a Dynamic expression, the clock of the kernel is used. Indeed, each second the kernel sends a message to the frontend, and the frontend starts an update procedure. So what happens when we close the ...


0

Probably some "magic" happens transparently when the items list is dynamic so the first {{date, 1}, dates, PopupMenu} is not equivalent to {{date, 1}, dates, PopupMenu[#, #2[[1]]]&} but to {{date, 1}, dates, Dynamic@PopupMenu[#, #2[[1,1]]]&} when #2[[1]] is a _Dynamic as in this case. Si I found this way: Manipulate[ If[updated, ...


1

As Fred has suggested, Initialization is the way to go, and here is a minimal example: DynamicModule[{answer, answers = Range@10, order}, Column[{ "Pick 1:", Dynamic[RadioButtonBar[Dynamic@answer, answers[[order]]], TrackedSymbols :> {order}] }] , Initialization :> ( order = RandomSample@Range@Length@answers; ), ...


0

While Fred Simons's answer is more flexible, I thought I'd add my own for the record because it doesn't depend on the EventHandler structure, nor any specific graphics drawn on the notebook. It seems that one can get access to MousePosition[] through CurrentValue[] which allows something like: dt = 1/100; (* 1/dt samples per second *) While[ ...


1

for completeness here is the LocatorPane version suggested by @m_goldberg comment. DynamicModule[{pt = RandomReal[{-1, 1}, {3, 2}]}, LocatorPane[Dynamic@pt, Graphics[{Circle[], Line[{{0, 0}, Dynamic@pt[[#]]}] & /@ Range@Length@pt}]]]


3

n = 3; Manipulate[Graphics[{Circle[{0, 0}],Line[{{0, 0}, a[[#]]} & /@Range[Length@a]]}], {{a, RandomReal[{0, 1}, {n, 2}]}, Locator, LocatorAutoCreate -> True}] Alternatively, Manipulate[Graphics[{Circle[{0, 0}], Line[Tuples[{{{0, 0}}, a}]]}], {{a, RandomReal[{0, 1}, {n, 2}]}, Locator, LocatorAutoCreate -> True}]


1

The following might give you some idea how it could be done. I assume that your regions are given by a Boolean function of two arguments, and therefore can be displayed with RegionPlot. For example, when your region is a circle, the region function is region=#1^2+#2^2<=1& and the region can be displayed as follows: RegionPlot[region[x,y], ...


3

Specifying an explicit PlotRange and moving the Dynamic outside the list in Graphics3D seems to create a smoother experience: DynamicModule[{vv = {0, 0, 1}, vp = {1.3`, -2.4`, 2.`}}, Graphics3D[ Dynamic[{Cuboid[], Line[{{0, 0, 0}, vv}]}], ViewPoint -> Dynamic[vp], ViewVertical -> Dynamic[vv], Boxed -> False, SphericalRegion ...


1

You may consider moving the variables used for the dynamic clock into a dedicated context Dynamic[{clock`d, clock`h, clock`m, clock`s} = List @@ DateDifference[Now, DateObject[{2015, 5, 18}], {"Day", "Hour", "Minute", "Second"}][[1]]; Grid[Transpose@{{"d", clock`d}, {"h", clock`h}, {"m", clock`m}, {"s", Round@clock`s}}, Alignment ...


3

Download code You can download a notebook with all the code in it by running the following code: Import["http://goo.gl/NaH6rM"]["http://i.stack.imgur.com/sMWJ2.png"] Code with comments The first thing to do is to separate your headings from your data: rawdata = {{"n", "t(n)", "t(n)/t(n-1)", "Ø(t(n)/t(n-1))"}, {20., 1.15, "", 1.30081}, {21., 1.54, ...


3

Is this what you mean? Manipulate[ Grid[{{txt}, {idx}}], Grid[{ {"T", InputField[Dynamic[txt, {txt = #; idx = StringLength[txt]} &], String, ContinuousAction -> True]}, {"index", Manipulator[Dynamic[idx, {idx = #} &], {0, Dynamic@StringLength[txt], 1}], Dynamic[idx]} }], {{txt, ""}, None}, {{idx, 0}, None} ]


2

I agree with Rojo's comments under his answer and I'd upvote them but the example from tutorials given in his answer is more confusing than educational for me (as expressed in comments). "For me", not "in my opinion" so maybe one can learn more from this part of tutorial. Nevertheless, I want to show you examples were using Refresh really matters. Refresh ...


3

It seems to work if I remove the extraneous calls to Dynamic. Manipulate[ {p[[#]] & /@ Range[5], Select[p[[#]] & /@ Range[5], (#[[1]] != #[[2]]) &]} // TableForm, {p, None}, {{np, "", "Test"}, Column[{Dynamic[sP /@ Range[5] // Row, TrackedSymbols :> {np}]}] &}, Initialization :> ( np = 5; sP[i_] := ...


2

I observe no problem here: make[] := Manipulate[x^2, {x, 1, 5}] PasteButton["A dynamic object", make[]] // CreatePalette Perhaps you forgot to localize your variables with DynamicModule which Manipulate makes use of automatically?



Top 50 recent answers are included