Hot answers tagged

7

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


7

There are a lot of different ways to do this. My current favorite is Manipulate[{a, b}, {a, 1, 10}, {b, 1, 10, TrackingFunction -> (b = #; a = 10; &)}]


7

An adaption of this answer for an ActionMenu and to your styling: assnMenuK[slowF_, a_Association, title_: "Choose"] := DynamicModule[{done = False, lastSelection = ""}, Grid[{{ ActionMenu[title, KeyValueMap[#2 :> (lastSelection = #2; done = "working"; slowF[#1]; done = True) &, a], Method -> "Queued"], ...


6

There's no way to do this that conforms fully to UI guidelines (at least not for OS X). For example, your "disabled" items will still highlight as you hover over them and will still react to selection (thought they will do nothing). This is as close as you can get: Manipulate[ {filter, list} , {{filter, 1, "Filter:"}, {1, 2, 3, 4, 5, 6}, ControlType ...


6

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


6

Something like this? Manipulate[ Plot[Sin[x] + a, {x, -3, 3}], OpenerView[{"open to control ", Control[{{a, 1, "a"}, 0, 10, 1}]}] ]


6

Manipulate[None, Grid[{ {Dynamic@ListPlot[{a, b, c, d}], Grid[{ {Style["a and b in a column on the right", Orange, Bold]}, {Control[{{a, 1, "a->"}, 0, 5, Appearance -> "Open"}]}, {Control[{{b, 1, "b->"}, 0, 5, Appearance -> "Open"}]} }], Grid[{ {Style["c and d in a column on the more right", Blue, ...


6

I'm not sure about all the arguments, but maybe this will get you started: Clear[MultiSlider]; MultiSlider[Dynamic[xs_], {st_, end_}] := LocatorPane[Dynamic[xs], Graphics[{LightGray, Thickness[0.015], Line[{{st, 0}, {end, 0}}]}], {{st, 0}, {end, 0}}] Manipulate[ x, {{x, Table[{2 i, 0}, {i, 5}]}, 0, 12, MultiSlider[##] &}] You can constrain ...


5

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


5

Try this Button["Evaluate", Speak["Let me think..."]; Pause[3]; (* Here all the task code *) Speak["I shall learn to make good questions and show my own efforts"]; SystemOpen["http://mathematica.stackexchange.com/help/how-to-ask"] , Method -> "Queued"]


4

Edit In my opinion, what is asked for is more easily done when the button graphics and the model graphics are kept in separate lists. Manipulate[ Column[{ Graphics3D[ MapIndexed[ If[FreeQ[u, models[[#2[[1]]]]], Button[#[[1]], AppendTo[u, models[[#2[[1]]]]]], Button[#[[1]], u = DeleteCases[u, models[[#2[[1]]]]]]] ...


4

Ok, I read it again and again and I think I know what you are after. Here's quick fix/adjustment to make this thing a valid controller: SetAttributes[customColorSetter, HoldFirst] customColorSetter[var_] := ( If[! MatchQ[var, _RGBColor], var = Black]; Delete[ FrontEndResource["RGBColorValueSelector"][[1, 1]], {{1, 1}} ] /. ...


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 *)


4

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


4

The question seems to be expounded somewhat and also answered in a comment by John Fultz: I received an internal bug report indicating that the underlying code was the same as referenced in this question. If so, this is not a bug. The code was something of the form Manipulate[Graphics3D[Cone[], ViewPoint -> RotationMatrix[t, {0, 0, 1}].{1.3, -2.4, ...


4

two things to consider: FileNameSetter is used to generate a button which then subsequently gets pressed to open a window. When a window opens for you to select a file it is best to use the queued evaluation channel rather than preemptive. Try this instead: ActionMenu["select an option", {"choose a file" :> (x=SystemDialogInput["FileOpen"])}, ...


4

A simple way is to define your Manipulate variable parameters so that they are recognised as the control type you want. Look in the first part of the Details and Options section of Manipulate documentation. Manipulate[ Plot[Sin[a + b x], {x, 0, 10}], {{a, 0}, {0, 1}}, {b, 1, 5}] You can get fancier by specifying the controls and layout directly. ...


3

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


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

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


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

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

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

There are two issues here. The first one can be explained easily because you simply forgot that your button needs to do something. Just evaluating your Manipulate is not going to do what you like, because you need to see it on screen when you want to interact with it. Therefore, you need to Print or CellPrint your Manipulate. The second issue arises when ...


3

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 Dynamic for r4 was changed to actually set the value of r4 upon an update. Manipulate[ Row@start, {{r2, "q", "R2"}, {"p", "m", "q", ...


3

It's a DynamicModule not a Manipulate, but it works (Mma V10.1 on Mac and Windows) DynamicModule[{filter, list = 1}, Column[{ PopupMenu[Dynamic[filter], Range[6]], PopupMenu[Dynamic[list], Table[With[{i = i}, (If[i < filter, list = list, list = i]) -> i], {i, 6}]], {"filter", Dynamic[filter]}, {"list", Dynamic[list]} }]] ...


3

Since this has gone unanswered for so long and I can add one clarification to the comments under the question, I'll fill out an answer. In the comments, it has been observed that the following work (with the appropriate definition of customControl): {{x, 0}, customControl[#1, y] &} {{x, 0}, customControl[Dynamic[x]] &} {{x, 0}, ...


3

There are couple of ways to handle your problem. Simple -- give a warning of slider interference: Manipulate[ If[t1 < t2, Plot[t^2, {t, t1, t2}], "Warning: t1 > t2"], {{t1, -1}, -2, 2, 0.1, Appearance -> "Labeled"}, {{t2, 1}, -2, 2, 0.1, Appearance -> "Labeled"}] More elegant user interface, less elegant code -- prevent slider ...


3

ControlActive doesn't respond to SetterBar, as changing a value using SetterBar doesn't make $ControlActiveSetting being True. Here is one way to make using the SetterBar reset k: Manipulate[ Row[{x, Spacer[10], y, Spacer[10], ControlActive[k = 0, k++], Spacer[10], $ControlActiveSetting}], {x, {5, 6, 7, 8}, ControlType -> SetterBar, ...


3

I guess OP wants to read out the result of the "set of instructions": Button["Evaluate", Module[{res}, Speak["Please wait your expression is being evaluated"]; res = Integrate[1/(x^3 + 1), x]; Speak["Your Answer is"]; Pause[0.1]; Speak[res]; Pause[0.1]; Speak["period"] ], Method -> ...



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