Tag Info

Hot answers tagged

10

Dynamic has this build into it. You can take advantage of the Dynamic second and third arguments. The second argument of evaluate as the dynamic is being updated. The third argument is evaluated when the mouse is released. Which is what you want. To illustrate, here is an example, where f[r] and g[r] are inside the arguments of the slider itself. This is ...


10

CurrentValue["ControlsFontFamily"] (* "Segoe UI" on Version 9 / Windows 8 *) (* "Lucida Grande" on OS X 10.6.8 -- thanks: m_goldberg *) (* "Bitstream Vera Sans" on Fedora 20 -- thanks Oska *) CurrentValue["ControlsFontSize"] (* 12 on Version 9 / Windows 8 *) Style[StringJoin[CharacterRange["a", "z"]], FontFamily :> CurrentValue["ControlsFontFamily"], ...


9

ControlActive is useful for this purpose: DynamicModule[{r = 1, old = 1} , Grid[ { {Slider[Dynamic[r]], SpanFromLeft} , {Dynamic[f[r]], Dynamic[g[ControlActive[r, old = r]; old]]} } ] ] The variable old has been introduced to hold the "old" value of r. The key expression is ControlActive[r, old = r]; old, which always returns the value of ...


5

I do nor know how to implement what you want to do in a Manipulate expression using locators, because I don't know how to handle mouse events in a Manipulate expression. However, if you are willing to accept an answer using EventHandler, the behavior you ask for isn't very difficult to implement. With[{δ = .2}, DynamicModule[{p1 = {0, 0}, p2 = {2, 2}, ...


5

This is what I find more intuitive: circle[] := DynamicModule[{a = {0, 0}, b = {1, 0}, r = 1, w}, { Dynamic@Circle[a, r], Locator[Dynamic[a, {(w = b - a) &, (a = #; b = a + w) &, None}]], Locator[Dynamic[b, (b = #; r = Norm[b - a]) &]] }] Graphics[circle[], Frame -> True, PlotRange -> 2] And this is what fits well ...


5

Perhaps this? Manipulate[ {names, slide, setter, cases}, Dynamic@Switch[cases, "custom", Control[{{names, True}, {True, False}}], "a", Control[{{slide, 0}, 0, 1}], "b", Control[{{setter, "das"}, {"das", "der", "die"}}]], {{cases, "custom"}, {"custom", "a", "b"}}] The variables seem to get localized properly even though the syntax ...


5

I'm adding this answer late because I think it would be good to have an example of OpenerView given as an argument to Manipulate, a common use-case for OpenerView. I also want to point out a special consideration which must be made when specifying controls in such a situation. SeedRandom[3]; With[{nMax = 16, rMax = 12., extent = 300}, With[{redPts = ...


5

For example: Manipulate[ LocatorPane[Dynamic[{x, y}], Graphics[{Red, Disk[]}]], {{x, 0}, InputField}, {{y, 0}, InputField} ]


5

That is how you might do it within the framework of Manipulate: Manipulate[ Plot[a*x^3 + b*x^2 + c*x + d, {x, -4, 4}], Row[{Control[{{a, 1, "a"}, 0, 3}], Spacer[20], Control[{{b, 2, "b"}, 0, 5}]}], Row[{Control[{{c, 1, "c"}, 0, 4}], Spacer[20], Control[{{d, 0, "d"}, 0, 2}]}], ControlPlacement -> {Top, Top, Bottom, Bottom} ] It ...


5

You might use Row. For example: Manipulate[{u, v}, Row[{Control[{u, 0, 6}], Control[{v, 10, 20}]}, Spacer[10]]]


5

Here is an option: Manipulate[{}, Dynamic@If[visible != "hide x-slider", Control[{x, 0, 1}], Invisible@Control[{x, 0, 1}]], {visible, {"hide x-slider", "show x-slider"}, ControlType -> PopupMenu}]


4

Not much to add to the code below. Indeed, it seems EventHandler is a solution to your problem. You need PassEventsDown to let the slider update. DynamicModule[{r = 1, s = 1}, EventHandler[ Grid[ { {Slider[Dynamic[r]], SpanFromLeft}, {Dynamic[f[r]], Dynamic[g[s]]} } ], {"MouseUp" :> (s = r)}, PassEventsDown -> True ] ]


4

Is this what you are after? DynamicModule[{x = 0, x2 = 0}, Framed[ Column[{ Dynamic[{"a", "b", "c"}.{x, x2, 1 - x - x2}], LabeledSlider[Dynamic[x, (x = #; x2 = Min[x2, 1 - x];) &], {0, 1}], Dynamic@LabeledSlider[Dynamic[x2], {0, 1 - x}] }] , Alignment -> Center, ImageSize -> {400, 100}]] Or maybe, other way when x and x2 ...


4

The padding is approximately eight percent both at the top and the bottom, so this will work pretty good: Scaled[{0, 0.08 + 0.84 length/100}] To understand how I got it, try substituting 0 and 100 respectively for length.


4

You can try something like: RemoveScheduledTask @ ScheduledTasks[]; RunScheduledTask[c = Round[ControllerState["Y Axis"], .1], .1] Dynamic[{RandomReal[], c}] (*RandomReal tells us when c triggers updating*) Plot[{Sin[x]}, {x, 0, 2}, GridLines -> Dynamic[{{1}, {c}}]] So the Dynamic is not triggered by controller itself but by the value of it. It will ...


3

You could label the points: Manipulate[ Column[{Dynamic@ Grid@Map[Pane[#, {60, 20}] &, Transpose@points, {2}]}], {{points, ({#, 0.1} &) /@ {-1, -1.5, 1.5, 1}}, LocatorPane[ Dynamic[points, (points = {#, 0.1} & /@ First /@ #) &], Graphics[{}, PlotRange -> {{-2, 2}, {-.5, .5}}, AxesOrigin -> {0, 0}, Axes ...


3

With Manipulate, you can demonstrate the relationship of the three simplex coordinates. Since x and x2 define the value of x3, I added Enabled -> False to its controller. Another way would be to set up some rules about which variable to decrease if any of the three variables is increased (i.e. decrease x3 if x or x2 is increased, decrease x if x3 or x2 is ...


3

A couple more ways. PaneSelector, with a blank Row: Manipulate[{x, y}, PaneSelector[{True -> Control[{x, 0, 1}], False -> Row[{}]}, Dynamic[visible != "only y-slider visible"]], PaneSelector[{True -> Control[{y, 0, 1}], False -> Row[{}]}, Dynamic[visible != "only x-slider visible"]], {visible, {"only x-slider visible", "only y-slider ...


3

Edited I don't like this much because what I take are intended to be the osculating circles don't have a radius equal to the radius of curvature. I used your formula, but it appears to be wrong. Nevertheless, what I've worked out does install a popup menu into a Manipulate expression which will select which parametric function will be displayed. It will ...


3

The problem is, that the Head of series is now Dynamic. With a simple Part you get rid of this: ListPlot[series[[1]], PlotLabel -> title] Besides, why not using Manipulate? Your problem seem perfectly suited for this: Manipulate[ forest = Range[30]; energy = Reverse[Range[30]]; Switch[choice , 1, series = forest; title = "Tree Growth" , 2, ...


2

I had to struggle with similar things before, and I found that the best way to control location of controls with respect to output they affect is to discard the whole Manipulate display area and do everything in the control area itself using Dynamics. This way you can control exactly where each slider/controller is located. This is done using basic Grid ...


2

I think you just have to experiment with adjusting the Sine plot. Here is what I got by doing a little trial and error work. Manipulate[Plot[a b c x, {x, 0, 100}, PlotRange -> {0, 100}], {{a, 1}, 0, 2, Appearance -> "Labeled"}, {{b1, 1}, 0, 2, Appearance -> "Labeled"}, {{b2, 1}, 0, 2, Appearance -> "Labeled"}, Dynamic[Plot[Sin[t], {t, 0, ...


2

As hinted in the comment, you might try it this way: Manipulate[ Column[{Style[{{a, 0, 0}, {0, b, 0}, {0, 0, c}} // MatrixForm, FontSize -> 18, FontColor -> Black, TextAlignment -> Left], Graphics3D[{GraphicsComplex[streckung[a, b, c], Polygon[i]]}, Axes -> True, Boxed -> True, PlotRange -> {{-5, 5}, {-5, 5}, {-5, 5}}, ...


2

You can place any controls inside an OpenerView: OpenerView[{"ButtonGroup", Column[{ Button["P5", Print[5!]], Button["P7", Print[7!]] }] }] Instead of OpenerView you could also use TabView or SlideView. I use this quite often to group, hide and open controls within a complex Manipulate. Keeps the screen clean.


2

Try this: OpenerView[{"", Column[{a^2 + b^2, Plot[Sin[x], {x, 0, 2 \[Pi]}], Speak["This is the opener view"]}]}]


2

Personally, I would stay with your first example, but if you insist on a more loose coupling between the button and the Export expression, maybe something like the following: filePath = FileNameJoin[{HomeDirectory[], "DeskTop", "test.jpg"}]; Manipulate[ p = Plot[Sin[x - n], {x, 0, 4 Pi}, ImageSize -> 300]; If[export, Export[filePath, p]; export = ...


2

I don't understand why, but If I put the ExcelLink Function outside of PopupMenu, the problem goes away, as seen below:


1

x = {3, 3}; y = {5, 3}; LocatorPane[Dynamic[{x, y}], Dynamic@Graphics[{{Gray, Circle[x, Abs[y[[1]] - x[[1]]]]}, {Blue, PointSize[0.02], Point[{x, {y[[1]], x[[2]]}}]}}, Axes -> True, PlotRange -> {{-2, 8}, {-2, 8}}, AxesOrigin -> {0, 0}], Appearance -> None]


1

I believe the jump in value of asd happens because you're dragging the indicator with the mouse when the range is reset. Here is a way that does what you want, I think. It interrupts the mouse-dragging by creating a new Slider when the boundary is reached. {Dynamic@asd, Dynamic@Slider[Dynamic[asd], Which[asd < 10, {1, 10}, asd >= 10, {9, 50, ...


1

I have a way of doing this by wrapping the label with a Panel. This has two effects: organizes space making a view more accurate and prevents jerking. Since you gave no code that can be played with, only the controls, I make here a simple example with two controls, just to demonstrate the way. Here you are: Manipulate[ Plot[Sin[\[Theta]*x], {x, 0, 2 ...



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