New answers tagged

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 @ ...


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


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 ...


1

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 ...


0

this is an answer also a question at the same time. I am simply trying to avoid using sliders and predefined functions to increase the capacity of the CDF file. I changed my example to taking integral and use inputfield for the function and upper and lower limit. It completely functional but not best presentation and controls. Here is the code ...


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 ...


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 ...


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 ...


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}; ...


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 ...


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 ...


0

I think there is no general/stable way to prompt kernel blocking dialog from another kernel blocking dialog. answerPrompt[] := Input["Give me the answer please."]; confirmationPrompt[] := ChoiceDialog["Are you sure?"]; You don't need to do that though. Use the code below in your Do loop to answer and confirm questions: While[ answer = answerPrompt[]; ...


1

Not sure why you define x and then never use it but despite that try this: ret = DialogInput[ DialogNotebook[{ DynamicModule[{input}, Grid[{{"f(x)=", InputField[Dynamic[input], String]}, {"", "Input expression f(x)"}, {"", DefaultButton["OK", DialogReturn[input]]}}, Spacings -> {0.5, Automatic}, Alignment -> ...


4

The last command in the question contains a solution: the graphics locator does what we want, we do not need the pane locator. So we position the graphics locator on the pane locator and make the pane locator permanently invisible. Instead of the appearances graphicsyes and graphicsno, we use a graphics expression for the crosshair and the empty string for ...



Top 50 recent answers are included