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


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

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}]


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


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

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

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

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


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

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

This is not an answer but an extended comment on andre's answer. I up-voted the answer because it's basically a good one. However, I want to point out two problems with the answer as posted. The following doesn't work because y has a value when mchoice is called. y = 42; Dynamic @ y mchoice["argon", {"solid", "liquid", "gas"}, 3, y] The following ...


3

Inside a Manipulate it's pretty straightforward: this[x_] := x; that[x_] := x^2; Manipulate[p[3], {p, {this, that}}] Here p takes on value of one of the function names, and then the chosen function is executed when the button is pressed.


3

Here are a couple variations, including Kuba's ButtonBar, which has yet to be posted as an answer. buttonFunctionBar[lbls_, func_, opts : OptionsPattern[ButtonBar]] := ButtonBar[# :> func[#] & /@ lbls, opts]; actionFunctionMenu[title_, lbls_, func_, opts : OptionsPattern[ActionMenu]] := ActionMenu[title, # :> func[#] & /@ lbls, opts]; ...


3

There is really a general method build into Dynamics in Mathematica meant for these things. It is the second argument of dynamics. One can think of the second argument of Dynamics as an event callback. In GUI, this acts exactly as an event callback in traditional GUI programming, where when one changes state of a UI control, a callback is fired, where one ...


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

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


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

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

So you want a SetterBar which provides the argument values to a function Foo? Isn't the most simple way to do this {SetterBar[Dynamic[y], Range[5]], Dynamic[Foo[y]]} Without explicit Dynamic there is maybe really only the solution which was already pointed out by bill s. Manipulate[Foo[v], {v, {1, 2, 3, 4}}] Or if you want it packed into a ...


2

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


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


1

Initialization for CheckboxBar works pretty much as for any type of control. {{checkBoxes, initial-checked-values, ""}, value-list, ControlType -> CheckboxBar}] For example, Manipulate[Row[{"Boxes checked: ", Length@checkBoxes}], {{checkBoxes, {1, 3}, ""}, {1, 2, 3, 4}, ControlType -> CheckboxBar}] will produce the following initial state when ...


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


1

I downloaded and examined the CDF you refer to. I conclude from my examination that what looks like a highly stylized TabView may actually be a custom control built based on EvenHandler. Often when one sees what look like fancy versions of Mathematica controls in sophisticated CDFs, they are custom replacements such as the one you were looking at. As far as ...



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