Hot answers tagged

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

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

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

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


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


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

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

It seems that Control is just a wrapper for Manipulate`Control, and that function expects a Symbol as its first argument: Control[]; (*preload*) ClearAttributes[Manipulate`Control, {Protected, ReadProtected}] Block[{$Context = "Manipulate`Dump`"}, Definition[Manipulate`Control] // Print; ] Manipulate`Control[var_, Manipulate`Dump`opts___Rule, ...


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

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

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

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

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


3

A modified version of the solution provided by Kuba, that behaves like an ActionMenu with the option setting Method -> "Queued" popupActionMenu[lbl_, actions_] := DynamicModule[{x, trigger}, Row[{PopupMenu[Dynamic[Refresh[x, TrackedSymbols :> {}], (trigger =.; trigger = #) &], First /@ actions, lbl, BaseStyle -> "ActionMenu", ...


3

Since a PopupMenu exhibits a behavior you are after, let's adjust it to act like an ActionMenu: myActionMenu[lbl_, actions_, opts___] := DynamicModule[{x = Unique[x]}, PopupMenu[Dynamic[x, (# /. actions) &], First /@ actions, lbl, opts] ] myActionMenu[ "Print Factorials", {"4!" :> Print[4!], "7!" :> Print[7!], "10!" :> Print[10!]} ] ...


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

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

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

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

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


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


2

Use the function: "EventHandler", just like follows: reportDate = Today; a = Dynamic[ With[{date = Interpreter["Date"][reportDateInput]}, If[DateObjectQ@date, reportDate = date, reportDate]], TrackedSymbols :> {reportDateInput}]; b = InputField[ Dynamic[reportDateInput, {None, With[{date = Interpreter["Date"][#]}, ...


2

Expanding on Kuba's answers, if you use Dynamic for both controls I believe you can fully accomplish your goal. When you set filter it will both gray out the elements less than the filter in list and if the element in list is less than the filter it will reset it to the filter value. Manipulate[ {filter, list}, (* Manipulate Controls *) {{filter, 1}, ...


2

As Arnoud Buzing has mentioned, when manually entering an RGBColor, in the code completion we find a user interface for finding the color components. This user interface is the same as that turns up when we click on a displayed RGBColor expression. I was wondering if this new interface could be used with Dynamic as well. Kuba showed that when we replace one ...


2

Specify a control: FormFunction[{"mm" -> <| "Label" -> labelimage, "Interpreter" -> "Boolean", "Control" -> Function[Toggler[#, {True -> checkimage, False -> uncheckimage}, uncheckimage]] |>}][]



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