Tag Info

Hot answers tagged

11

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"], ...


6

One difficulty in using Manipulate is that it rewrites your code for you in ways that are not clearly explained in the documentation. The thinking is that this rewriting achieves the dynamic interactions described in the documentation without burdening the programmer with some of the tedious details involved. For instance, expressions that contain ...


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

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

Less ambitious: addbutton[manipulate_] := With[{box = ToBoxes@manipulate}, With[{proc = Cases[box, HoldPattern["Variables" :> _], ∞]}, With[{button = Button["Reset", CompoundExpression["Variables"] /. proc]}, Composition[ToExpression, BoxData][ box /. {("Body" :> x_) :> "Body" :> Column[{button, x}]}]]]] ...


5

I do this all the time, but use small buttons next to the slider. This is handy when one wants to jump to specific value, and sometimes it is hard to get the slider to go there exactly without few hits and misses and one ends up opening the slider using "+" and typing in the value in the small window which is not very efficient sometimes. Here is an example ...


4

With small modifications of the code provided by m_goldberg you can get the Button and the ProgressIndicator in the same Row. However, it is always there now and will not appear and disappear. DynamicModule[{n = 1}, Row[{Button["Start", n = 1; Do[Pause[0.1]; ++n, {i, 1, 100}], Method -> "Queued"], Spacer[23], Dynamic[ProgressIndicator[n, {1, ...


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


4

This is a bug in the Mathematica FrontEnd that appears on systems running Mac OS X 10.10. The cause is a change, beginning with Yosemite, in the behavior of the API used to draw the popup arrow. The FrontEnd bug will be fixed in an upcoming release.


4

You need to do some initialization. Manipulate often behaves strangely when its controls are not initialized properly. f[u_] := If[u <= 1, 5, 0]; Manipulate[ Column[{ Row[{"x: ", x, " f[x]: ", f[x]}], Row[{"ang: ", ang, " f[ang]: ", f[ang]}]}], {x, 0, 2}, {{ang, x}, x, 2}] (* initialization added to control *)


3

I reported the issue discussed in this question to Wolfram technical support. I have received the following reply: It does appear that Animator is not behaving properly in this case and I have forwarded an incident report to our developers with the information you provided. On the basis of this reply, I have tagged this question with bugs.


3

Is this what you mean? Manipulate[ Grid[{{txt}, {idx}}], Grid[{ {"T", InputField[Dynamic[txt, {txt = #; idx = StringLength[txt]} &], String, ContinuousAction -> True]}, {"index", Manipulator[Dynamic[idx, {idx = #} &], {0, Dynamic@StringLength[txt], 1}], Dynamic[idx]} }], {{txt, ""}, None}, {{idx, 0}, None} ]


3

Not completely tested, based on undocumented structure of the DynamicModule constructed by Manipulate -- but it works for now: Manipulate[a + b + c, {{a, 1}, 0, 5}, {{b, 2}, 0, 5}, {c, 0, 5}, Button["Reset", Replace[ Typeset`specs, {{{Hold[var_Symbol], val_}, ___} :> (var = val), {Hold[var_Symbol], val_, ___} :> (var = val)}, 1]] ] ...


3

The closest I can get to what you ask for is DynamicModule[{n}, Button["Start", n = 0; Monitor[Do[Pause[0.1]; ++n, {i, 1, 100}], Dynamic[ProgressIndicator[n, {1, 100}]]], Method -> "Queued"]] which, after the button is clicked on, produces The progress indicator appears in its own temporary cell, not in a row with the button. ...


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


3

One can slightly rewrite your code and obtain a nice Manipulate f[x_, a_, μ_, σ_] := a Exp[-(x - μ)^2/(2 σ^2)]/(Sqrt[2 π] σ) n = 3; vars = Through@{a, μ, σ}@# & /@ Range[n]; func = f[x, ##] & @@@ vars; values = {{50, 5, 20}, {50, 50, 40}, {100, 80, 20}}; rangelow = 0.7 values; rangehigh = 1.3 values; With[{func = func}, Manipulate[Plot[func, ...


3

Dialogs are notebooks with different from regular options settings, so you can export save them as you want: (that is the case with palettes too) Export[ FileNameJoin[{$TemporaryDirectory, "myDialog.nb"}], CreateDialog[ Column[{ InputField[Dynamic[a], Number, FieldHint -> "enter a"], InputField[Dynamic[b], Number, FieldHint ...


3

Download code You can download a notebook with all the code in it by running the following code: Import["http://goo.gl/NaH6rM"]["http://i.stack.imgur.com/sMWJ2.png"] Code with comments The first thing to do is to separate your headings from your data: rawdata = {{"n", "t(n)", "t(n)/t(n-1)", "Ø(t(n)/t(n-1))"}, {20., 1.15, "", 1.30081}, {21., 1.54, ...


3

n = 3; Manipulate[Graphics[{Circle[{0, 0}],Line[{{0, 0}, a[[#]]} & /@Range[Length@a]]}], {{a, RandomReal[{0, 1}, {n, 2}]}, Locator, LocatorAutoCreate -> True}] Alternatively, Manipulate[Graphics[{Circle[{0, 0}], Line[Tuples[{{{0, 0}}, a}]]}], {{a, RandomReal[{0, 1}, {n, 2}]}, Locator, LocatorAutoCreate -> True}]


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

Generally, Dynamic is used in two ways: Re-evaluating expressions when they would change, and displaying the result. The syntax is Dynamic[expr]. Dynamic[expr] cannot be used to represent the value of expr in different context and calculate with it. It is only used to display it. Allowing controls to change values of variables. Typical syntax: ...


2

If you are not insisting on calling the Manipulate-menu's bookmark, the following approach might do the job: Manipulate[Column[{Plot[TriangleWave[a x], {x, 0, 1}], Button["Custom Reset", (* first go back within the notebook *) SelectionMove[EvaluationNotebook[], Previous, Cell]; SelectionMove[EvaluationNotebook[], Previous, Cell]; ...


2

Something like this?: data = {1, 1, 2, 2}; DynamicModule[{max = Tr @ data, x}, Manipulate[ Normal @ SparseArray[Thread[x -> 1], max], ## ] & @@ Thread[{x, Internal`PartitionRagged[Range@max, data], ControlType -> TogglerBar}] ]


2

Are there really sufficiently many assignable pixel locations such that you can drag a Controller to such a resolution? Would you be satisfied if the range were small enough that the MinIntervalSize you seek could be rendered? After all, this will work: IntervalSlider[{.003, .007}, {0., .010}, ImageSize -> 600, MinIntervalSize -> .00000001, ...


2

I do not understand everything the code is suppose to do, but passing the control as a pure function inside a variable declaration might give the desired behavior. The other change is the variable-setting function in the Dynamie for r4 was changed to actually set the value of r4 upon an update. Manipulate[ Row@start, {{r2, "q", "R2"}, {"p", "m", "q", ...


1

You have a few small mistakes which are easily fixed. Manipulate[ Dynamic @ Plot[f[x], {x, -10, 10}, PlotRange -> {-10, 10}], {{f, a # + b &}, {a # + b & -> "Linear", Abs[a # + b] & -> "Absolute Value"}, ControlType -> PopupMenu}, {{a, -2} -3, 3, 1, Appearance -> "Labeled"}, {{b, -3,}, -5, 5, 1, Appearance -> ...



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