Hot answers tagged

8

How can I constrain the locator to stay within the region defined by RegionPlot? You can check if locator's coordinates fulfill the condition defining your region. It can be done with the second argument of Dynamic if you introduce Locator explicitly. Take a look at line with Locator[Dynamic[p, With[{... A strange behavior occurs whenever the left ...


5

sec = 60; min = 1/60; hr = 1/60/12; wsp = Table[{Cos[x], Sin[x]}, {x, 2 \[Pi]/6, -9 \[Pi]/6, -\[Pi]/6}]; Animate[Graphics[{Table[{ColorData["TemperatureMap", i/12], Disk[wsp[[i]], 0.2], Text[Style[i, Black, Bold], wsp[[i]]]}, {i,1, 12}],Thick, Black, Arrowheads[Large], Arrow[{{0, 0}, {Sin[min 2 Pi t], Cos[min 2 Pi t]}}], Arrow[{{0, 0}, 0.8 {Sin[hr ...


5

I think this code answers the question: data = RandomInteger[{0, 1}, {120, 4}]; edges = DirectedEdge @@@ Partition[data, 2, 1]; Graph[edges, VertexLabels -> "Name"] Continuation... Because of a question in a comment here is some code that shows the derivation of graphs, spanning trees of those graphs, their disjoint union, and a highlighted ...


4

Shortly, use a SelectorPane and hide EventHandler as soon as the condition is met: pt = {0, .05}; pane = "dynamic"; graphics = Framed[Graphics[ {{Red, Disk[Dynamic[pt], .1]}}, PlotRange -> 1, Axes -> True] ]; eh = EventHandler[#, { "LeftArrowKeyDown" :> (pt -= {0.05, 0}; check@pt), "RightArrowKeyDown" :> (pt += {0.05, 0}; ...


3

It can also be done this way. I recommend it because it avoids passing any complicated dynamic expression to AngularGauge. Dynamic[ AngularGauge[ Quantity[DateDifference[Now, Tomorrow, "Minute"]], {Quantity[0, "Minute"], Quantity[800, "Minute"]}, GaugeLabels -> "Unit"], UpdateInterval -> 1] The tooltip confirms that the gauge is ...


3

Don't know why but if you have a Quantity[513.2441798845927, "Minutes"] wrapped with Dynamic, then AngularGauge can't handle it and shows two inputs, 513.23 and "Minutes" (blue one). I also don't know if that's suppose to happen but here's a work around: Use QuantityMagnitude: Dynamic[AngularGauge[ Dynamic[Refresh[ QuantityMagnitude @ ...


3

This seems a little cleaner to me: p = {0.5, 0.5}; LocatorPane[Dynamic[p], Graphics[{ {Yellow, Rectangle[]}, Dynamic @ Locator[p, ControlActive[Automatic, None]] }], Appearance -> None ]


3

Just to give back to community, here's a little piece of code: Item[KeyEvent["e", Modifiers -> {Control}], FrontEndExecute @ Module[{nb, t}, nb = InputNotebook[]; SelectionMove[nb, All, Expression]; t = NotebookRead[SelectedNotebook[]]; NotebookWrite[nb, ButtonBox[RowBox[{"(", CounterBox["Section", t], ".", ...


3

All you have to do is give ui the attribute HoldFirst. It also a good idea to make the image an argument of ui. That is, define SetAttributes[ui, HoldFirst]; ui[pts_, img_Image] := LocatorPane[ Dynamic[pts], Dynamic[ Show[ img, Graphics[ {Table[ Arrow[{pts[[i]], pts[[i + 1]]}], {i, 1, ...


3

It seems that sometimes Cells and friends are not smart enough to be aware of the parent notebook, supplying the code with EvaluationNotebook gives something working for me: Tooltip["TEST!", Dynamic @ Rasterize @ NotebookRead @ First @ Cells[ EvaluationNotebook[], CellTags -> "TestTag"] ] Is this what you are after?


2

This has been bugging non stop so I wanted to create a somewhat viable solution for Windows using autohotkey. Run the following as an Administrator in autohotkey on Windows. down=0 e:: if(down=0){ FileDelete, C:\Test.txt FileAppend, Down.`n, C:\Test.txt down=1 } return e Up:: Send e FileDelete, C:\Test.txt ...


2

Hope I understood your question correctly. I might require to modify the code if I misinterpreted your OP. Example: Manipulate[ Plot[f[x], {x, min, max}], {{f, Sin, "Function"}, {Sin, Cos, Tan}}, {{min, 0, "Min."}, 0, 2 Pi}, {{max, 2 Pi, "Min."}, 0, 2 Pi} ] Output:


2

There are a couple of issues. The floating-point arithmetic could result in a point close to (0, 0) without being equal to (0, 0). Use Chop. The Abort happens after pt is updated in EventHandler . So sequence of events is Press key. Update to (0, 0) (actually, really close to (0, 0)). Not (0, 0), so continue. Press key again. Update to not (0, 0). Not ...


2

I felt like it is something very fundamental for working with UI developement in MMA so I asked WRI Support to help me. It took a while but I received a very good answer, which is to suspend DynamicUpdating when Export takes place. [...] For the effect you want, turn off the global DynamicUpdating option for the fronend just before the call to ...


1

You can try with Manipulate Manipulate[Row[{SetterBar[Dynamic[y], Range[x]], Dynamic[y]}], {{x, 1,"Squares"}, InputField[#, Number] &}]


1

Perhaps something like: test[steps_] := Module[{}, n = 0; Print["% Complete: ", Dynamic[n*100/steps]]; For[n = 0, n < steps, n++, Pause[1]]; NotebookFind[SelectedNotebook[], "Print", All, CellStyle]; NotebookDelete[]] See also: A self-deleting button to delete Print cells


1

Here's another simple modification of your code that allows you to specify the function, Manipulate[ DynamicModule[{f = Sin}, Column[{InputField[Dynamic[f]], Dynamic[Plot[f[o x + p], {x, -5, 5}]]}]], {o, 1, 10}, {p, 2, 10}] Now you can change Sin to any built-in function that takes a single argument, and still modify o and p. You can even ...


1

You might want to describe the problem you are trying to solve in more detail, the comments indicate that people aren't sure about that. Here is what I think could be what you are after: With[{x = x},Dynamic[f[x, y]]] using With you can insert the current value of x into the Dynamic as a constant, so it will not change anymore. Whenever the definitions ...



Only top voted, non community-wiki answers of a minimum length are eligible