Tag Info

Hot answers tagged

10

I want to give an answer using SyntaxQ and SyntaxLength. SyntaxQ takes a string and returns True, when the string has correct Mathematica syntax. On the other hand SyntaxLength returns an integer which shows up to what character the string is correct syntax. If the integer is larger than the length of the input string it indicates, that more input is needed. ...


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

I am not sure why you can't just use Grid? Manipulate[Plot[Sin[x], {x, -lim, lim}], Grid[{ {Control[{{lim, Pi, "limit"}, Pi/10, 2 Pi, Pi/10, ImageSize -> Tiny}], Button["A", ImageSize -> 100]}, {Button["B", ImageSize -> 100], Button["C", ImageSize -> 100]}, {Button["D", ImageSize -> 100], Button["E", ImageSize -> 100]} ...


9

The answer is that yes, you can affect the appearance of components of a control but the problem in this case is that your list of appearances appearances = {"DialogBox", "Palette", "FramedPalette", "Frameless"}; are only valid Button appearances and that is why they have no effect of ButtonBar or TabView. When you use valid appearances it works fine: ...


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


8

You have to study the documentation carefully, but I agree that help-pages like the one of Manipulate are very densely packed with information. In the Details and Options section you find how to set options for controls: {{u,...},...,opts} control with particular options The non-obvious part is, that you have to set the ControlType as well to make ...


7

If you look at underlying code: ListAnimate[Table[Plot[Sin[n x], {x, 0, 10}], {n, 25}]] // InputForm at the end you'll find: which leads to a trick: ListAnimate[Table[Plot[Sin[n x], {x, 0, 10}], {n, 25}]] /. HoldPattern[AppearanceElements -> _] -> (AppearanceElements -> None) In the spirit of @Mr.Wizard comment you can also do something ...


7

You can use the Style setting ControlRendering to display controls in their generic form: Rotate[Style[Button["Toto", Null], ControlsRendering -> "Generic"], 0] If you don't see the bottom line you need to set the Buttons ImageMargins: Rotate[Style[Button["Toto", Null, ImageMargins -> 1], ControlsRendering -> "Generic"], 0.0]


7

You can always create your own custom controls. This is a lot of work, but it also gives you unlimited flexibility. You can even create completely new kinds of control. Scroll down to the last section here to see an example. If you're aiming for a custom TabView-like control, I'd start with PaneSelector. Here's a primitive example (just a start, not ...


6

If I use the option Method->"Queued" within Button, this works Button["Export", Export[SystemDialogInput["FileSave"], Plot[Cos[x], {x, 0, Pi}], "PDF"], Method -> "Queued"] Otherwise, "Preemptive" will be the default, making it possible that not enough time is allocated for the Button action to complete. See the reference docs on ...


6

DynamicModule[{n = 3, prefTable = ConstantArray[0, {3, 20, 7}], lastName = ConstantArray["", {3}], firstName = ConstantArray["", {3}], ws = ConstantArray[0, {3}], wsAmount = ConstantArray[Null, {3}], wkndPref = ConstantArray[Null, {3}], tabLabel = Array["Worker " <> ToString[#] &, {3}], hours = DateString[DatePlus[{2012, 1, 1, 7, ...


6

One way to achieve this would be to define a "clipping" function that applies the constraints to the points: clip[pts_] := ReplacePart[pts /. {x_, y_} /; y > x :> {x, x}, {-1, 1} -> 1] We can then invoke that function whenever the set of points is changed. To use this strategy, it is convenient to use a single locator control for all points: ...


5

I think HorizontalGauge is just buggy. It shouldn't trigger a dynamic update when you change its state but it does. Simplest case: HorizontalGauge[Dynamic[x]] // Dynamic I would try using this "fixed" version horizontalGauge = Refresh[HorizontalGauge[##], None] & By the way, you could stick this into the built-in symbol's definition, and perhaps if ...


5

Computing Processes are the number of main kernels you can use at the same time. Therefore, you can have on the same computer two Mathematica sessions running and while one computation is running, you can use the other one to do something else. It has nothing to do with your license which is valid for only one computer. The probably easiest method if you ...


5

I think you've got to take over placement manually. First declare the variable setter with no control (None). Next add a SetterBar. Put this inside a Pane so you can control placement. The ImageSize of the Pane needs to be determined by hand. You can use ImageSize -> Full, which makes it fill the width of the notebook window -- perhaps desirable or ...


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


4

Maybe something like this: Rotate[Framed[ Button["Toto", Null, Appearance -> "Frameless", BaseStyle -> {"GenericButton", 16, Bold}], RoundingRadius -> 5, Background -> GrayLevel[.95]], 0] Rotate[Framed[ Button["Toto", Null, Appearance -> "Frameless", BaseStyle -> {"GenericButton", 16, Bold}], RoundingRadius -> 5, ...


4

After reading some of the comments, I thought I'd post this solution I had done some years ago. It does not work through the Bookmarks. As noted, that requires converting things like FE`a$$712 to $CellContext`a$$ -- someone may know how to do that easily. I suspect it could be done. The code below accomplishes the same intention as the OP. It saves the ...


4

One can set variables equal to the controller values like below. They can then be used in a computation. Here I just scaled them by a. Manipulate[ {x0, y0, z0} = ControllerState[{"X", "Y", "Z"}, ControllerPath -> {"Sudden Motion Sensor"}]; a {x0, y0, z0}, {a, 1, 100} ] Controlling the view point of 3D graphics could be fun, except that it's ...


4

The problem is that Dynamic is preventing ToExpression from evaluating to a symbol. When you drag the slider it's trying to evaluate: ToExpression[ToString[h] <> ToString[1] = 0.1 and you get a message about not being able to set the value of ToExpression. I would use With to create the symbols and insert them into the Dynamic: w = ...


4

This will work. The only change is that I removed the option ControlType and added a "slider function" at the end of the control for v. Note that Pinguin Dirks suggestion in the comments also works, is more convenient and he beat me to it :). Still I guess this code shows how you can have even more control over your slider. Manipulate[ With[{ar = 1/(2*Pi), ...


4

Put your options inside your control (you don't need those cumbersome constructions with patterns and Dynamic@Animate): Animate[Plot[Sin[x + a], {x, 0, 10}, Filling -> 0], {{a, 0, ""}, 0, 5, AppearanceElements -> "PlayPauseButton"}, AnimationRunning -> False]


4

You can use DynamicWrapper[] : mchoice[question_, answers_, correct_, var_] := DynamicModule[{x}, DynamicWrapper[ Column[{ ActionMenu[question, MapThread[#1 :> (x = #2) &, {answers, Range@Length@answers}]], PaneSelector[MapThread[#1 -> #2 &, {Range@Length@answers, answers}], Dynamic[x]] }], var = (x == correct)]]


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

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

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


3

Adding the option TrackedSymbols :> {LowerLimit, UpperLimit} to the Dynamic[..] that holds HorizontalGauge fixes the issue: DynamicModule[{y = 1, LowerLimit = 1, UpperLimit = 10}, Column[{Row[{PopupMenu[Dynamic[LowerLimit], {1, 2, 3, 4}], PopupMenu[Dynamic[UpperLimit], {5, 6, 7, 8, 9, 10}]}], Dynamic[HorizontalGauge[Dynamic[y], {LowerLimit, ...


3

A natural solution is something like this: Manipulate[x, {x, 0, 1}, {{x, 0, ""}, 0, 1, Trigger, AppearanceElements -> "PlayPauseButton"}] or like this: Manipulate[x, {x, 0, 1, Animator, AppearanceElements -> {"ProgressSlider", "PlayPauseButton"}, AnimationRunning -> False}] where AppearanceElements control what type of ...


3

The 2 CONTROLLING processes effectively means you can run 2 front-ends at the same time. This might be, say, Mathematica 8 and Mathematica 9 on the same machine at the same time, or one copy of Mma 9 on your desktop and another on your laptop (if your License allows same: check with Wolfram). The COMPUTING processes (8) are the number of slaves / cores you ...



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