New answers tagged

7

I recently needed to do something like this. Here's a simplified version of what I came up with: DynamicModule[{elem = "Hydrogen"}, Panel[Row[{(ColorData["Atoms", "Panel"] /. HoldPattern["MouseClicked" :> rhs_] :> ("MouseClicked" :> (elem = CanonicalName[ElementData[Cases[Unevaluated[rhs], _Rule, ∞][[1, ...


2

Dynamic inside Manipulate A tip that I would like to contribute is to use Dynamic with controls such as sliders, checkboxes and input fields inside Manipulate. This enables one to place the control anywhere (even inside a figure) and to tie controls together. I typically initialize the controls by placing them in the normal spot for Manipulate but setting ...


5

Manipulate[Show[Graphics[dottedCircle1[{0, 0}, Pi/2 + a, R]], Graphics[dottedCircle2[{R + r, 0}, -Pi/2 + s a, r]], AspectRatio -> Automatic], {a, 0, 2 Pi}, {{R, 1}, 0, 10}, {{r, .5}, 0, 10}, {{s, 0}, 0, 10, 1}]


1

This will open a dialog notebook created by CreateDialog as soon as you "drive" over the left sideline. final = DynamicModule[{dialogQ = False}, {Graphics[{{White, Thick, Line[{{200, -500}, {200, 175000}}]}, {Yellow, Thick, Dashing[{.1, .05}], Line[{{500, -500}, {500, 175000}}]}, {White, Thick, Line[{{800, -500}, {800, 175000}}]}, ...


4

Here is my take on that: EventHandler[Dynamic@Refresh[ If[0 < handAngle - clickAngle < \[Pi]/30, EmitSound[Sound@SoundNote["C"]]]; handAngle = N@Mod[15 - DateValue[Now, "Second"], 60, -30] \[Pi]/30; Show[ClockGauge[], Graphics[Point[clickPoint]]], UpdateInterval -> 1], {"MouseClicked" :> (clickPoint = ...


2

Here is a quick first draft: DynamicModule[{s = 0, pt = {0, 1}}, Column@{ClickPane[ Dynamic[Show[Refresh[Graphics[ClockGauge[]], UpdateInterval -> 1], Graphics[{Red, Point[pt]}]]], (pt = #; s = 30*(1 + ArcTan[-pt[[2]], -pt[[1]]]/Pi)) &], DynamicWrapper[Dynamic@s, If[DateValue["Second"] == Round[s], ...


0

I tend to do manipulate for lightweight applications because it will auto refresh and I think it looks better. The auto refresh also helps with the user interface because I think it's more intuitive than having to press enter or even a button. Dynamic may be a better choice for applications where the user would want to set multiple parameters to a specific ...


0

Manipulate[Row[{ArrayPlot[mat[[;; k, ;; k]], ImageSize -> 300], AdjacencyGraph[mat[[;; k, ;; k]], ImageSize -> {300, 300}]}], {{mat, ConstantArray[0, {50, 50}]}, None}, {k, 4, None}, Dynamic[Column[{InputField[Dynamic[k, (k = Clip[IntegerPart@#, {2, 20}]) &], Number, FieldSize -> {8, 1}], ...


1

A bit simple minded: DynamicModule[{n = 3, bs}, Panel[Column[{Slider[Dynamic[n, {(n = #) &, (bs = PadRight[bs, {n, n}]) &}], {2, 100, 1}], Row[{Dynamic[Grid[Array[Checkbox[Dynamic[bs[[##]]], {0, 1}] &, ...


0

If Manipulate (my first choice for implementing your display function) can't be used, then I would fall back on DynamicModule. showContour[f_, k_] := DynamicModule[{xmin = 0, xmax = 100, ymin = 0, ymax = 100}, Dynamic @ Column[{ Row[{"x-min: ", InputField[Dynamic[xmin], Number]}], Row[{"x-max: ", InputField[Dynamic[xmax], Number]}], ...


2

Bug was fixed in version 10.4.0.0.


1

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


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


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



Top 50 recent answers are included