Tag Info

Hot answers tagged

8

You can get custom colors and rounded corners by adding a custom frame to a frameless InputField. The following code approximates the look of Wolfram Alpha's input field: With[{opts = {FrameMargins -> 0, ImageMargins -> 0}}, Framed[ Framed[InputField[, ImageSize -> {500, 25}, Appearance -> "Frameless"], FrameStyle -> ...


8

Yes, it is a bug. I am quite confident it will be fixed in an upcoming release.


7

You can achieve this functionality by Manipulate[{a, b, c}, Dynamic@Column@{ Control[{a, 0}], Control[{ShowMore, {False, True}}], Sequence @@ If[ShowMore, {Control[{b, 0}], Control[{c, 0}]}, {}] }] This is similar to the link provided by m_goldberg, but it has a more compact form more suitable for this question.


6

For simplicity, I'm using function downvalues as a backend (and not an array) (* Define functions *) bTable[action_, fArray_, dims_]:= Grid@Array[Button[{#1, #2}, action[fArray, #1, #2]]&, dims] action[fArray_, x_, y_] := (fArray[x, y] = fArray[x, y] + 1) (* or whatever *) (* Initialize *) dims = {3, 3}; Array[(f[#1, #2] = 0) &, dims]; (* Run *) ...


5

You can start from this, the answer is checked by Button or by pressing Enter. This may look like a lot of code. Well if your app is shor you do not need to play with Initialization and storing different elements in different variables but this is an approach that I'm using for more complicated cases, the code is readable and easy to extend. With[{ optG = ...


4

Here is an example of using ProgressIndicator. I added Pause[] to simulate some blocking operation, and added Abort button. This is the pattern that I use when using this feature. It is simple and works for me. The idea is to pass the tracking symbol by reference. Manipulate[(*example using progress monitor in Manipulate*) Module[{result}, abort = ...


4

But the answer is yes, You need Dynamic inside Plot3D Manipulate[ Plot3D[{x^2 + y^2, -x^2 - y^2}, {x, -2, 2}, {y, -2, 2}, RegionFunction -> Function[{x, y, z}, x^2 + y^2 <= 4], BoxRatios -> {1, 1, 1}, ViewPoint -> Dynamic@vp], Control[{{vp, {5, 8, 4},""}, {{5, 8, 4} -> "xyz", ...


4

Here is a toy example: qnam[q_, a_, alt_, nr_] := DynamicModule[ {ln, funs, var, enb, layout, cusum, vis = "", perc}, ln = Length[q]; enb = Table[Unique["e"], {ln}]; Map[(#[_] := True) &, enb]; funs = Table[Unique["f"], {ln}]; var = Table[Unique["v"], {ln}]; MapThread[(#1[u_] := If[u == #2, 1, 0]) &, {funs, a}]; layout = ...


4

This Answer is based upon Kuba's comment above regarding two InputFields, so credit should go to him for the idea, this is just an implementation. However, the problem interested me because I have a similar issue to solve regarding entering units into answers, and this question and Kuba's comment made me think of a related solution to that. One can use ...


4

It is because ResetButton refers to Manipulate`s initial state while pt is outer DynamicModule variable here. You can scope variables in Manipulate with a cool trick, which I've learned here: {{pt, {0.5, 0.5}}, None} Manipulate[ ArcTan @@ pt, {{pt, {0.5, 0.5}}, None}, DynamicModule[{}, LocatorPane[ Dynamic[pt], ...


3

pos = {}; SetOptions[EvaluationNotebook[], NotebookEventActions :> { "MouseClicked" :> If[CurrentValue["AltKey"], AppendTo[pos, MousePosition[]]], PassEventsDown -> True}] Dynamic@MousePosition[] Dynamic@pos So, while pressing Alt you can click to store your positions.


3

SparseArray is another tool for constructing arrays with regular patterns, SparseArray[{ {i_, j_} :> Button[ Row[{"(", i, ",", j, ")"}], actfunc[i, j]] }, {3, 4}] // Grid You can define/redefine your button function later, Clear[actfunc] actfunc[i_, j_] := arry[[i, j]] = RandomReal[] Then your data, arry = ConstantArray[0, {3, 4}]; ...


3

b.gatessucks was faster than I, so he already wrote about DynamicModule. Again, the answer you're looking for might very well be found in this thread. ybeltukov's answer is excellent. I want to publish this anyway as a boilerplate for people who want to go down the DynamicModule path. There are a few thing you have to do to mimic manipulate, like alignment, ...


2

You can find good suggestions using Manipulate in the link provided by @m_goldberg. An alternative, also mentioned there, is to use DynamicModule; below is a starting point. DynamicModule[{showMore, a, b , c}, Panel@With[{controlGenerate = Function[{var, initialValue, str, range, controlType}, Control[{{var, initialValue, str}, ...


2

There are two problems that have been alluded to by @Kuba and @amr. The first is that vp needs to be wrapped in Dynamic. This is because in the graphics output the value of vp is stored, not a reference to vp itself. Dynamic takes care of this, since it has the attribute HoldFirst. The further effect of wrapping vp in Dynamic has to do with how the front ...


2

As Kuba says, you can wrap the vp in Dynamic: Manipulate[ Plot3D[{x^2 + y^2, -x^2 - y^2}, {x, -2, 2}, {y, -2, 2}, RegionFunction -> Function[{x, y, z}, x^2 + y^2 <= 4], BoxRatios -> {1, 1, 1}, ViewPoint -> Dynamic[vp]], {{vp, {5, 8, 4}, ""}, {{5, 8, 4} -> "xyz", {0, -Infinity, 0} -> "xz", {0, 0, Infinity} -> "xy"}, ...


2

In version 9, there is the new built-in function ListPicker. It can be exploited for tabular data easily: ListPicker[{}, Riffle[ Thread[Range@Length@data -> (Grid[{#}, Dividers -> Center, ItemSize -> {{5, 8, 12}, 2}] & /@ data)], Delimiter], Spacings -> 0]


2

In version 7 this suppresses the Show Animation Controls tooltip but fails to suppress the Play, Step Forward etc. ones. Style[ Manipulate[Plot[Sin[x (1 + a x)], {x, 0, 6}], {a, 0, 2}], TooltipBoxOptions -> {DefaultLabelStyle -> {Opacity[0], 0}} ]


2

A similar approach where I simulated a grid of togglers: whichever button is pushed, its position is added to/removed from list. It is general enough to lay out ragged tables. num = 27; (* number of buttons *) edge = 6; (* edge size of grid *) list = {}; Dynamic@list Grid[MapIndexed[ Button[#2, list = If[MemberQ[list, #2], DeleteCases[list, #2], ...


2

This is more of a comment on some of the other answers. The problem with using If[test, display, (* else *) {}] type usage is that on its own it can lead to a lot of empty rows -- which we can see in other answers if a frame is added. e.g So the way to fix this in your "openers" is to use Join since Join[{{1, 2, 3}}, {}] (* {{1, 2, 3}} *) In other ...


2

I did analogous, when teaching my son to calculate. It is about addition, but is easily transformable for the multiplication. Below argue01.gif and cataround.gif are two movies that I took from a site with animated icons. They were stored in the same directory and loaded before the first evaluation of the game. If you will play the code without these movies ...


2

After some significant time browsing related questions on this site as well as trial and error, I believe that I have managed to create a solution for what I was trying to accomplish. Taking the advice from Ariel I have essentially created my own custom array of checkboxes that do not experience any major delay when one of them is clicked. I have ...


2

Just to provide a full answer (and thanks Kuba's answer) in case someone wants to screencast while using Mathematica and byzanz (Gnome only): recordGif::Usage = "Record Mathematica animations; Syntax: recordGif[time,delay]"; recordGif[time_, delay_] := DynamicModule[{pathToGif, pathToSh, toGIF, posGIF}, Panel@Column[{ Button["Run", Print["Starting ...


2

Quick fix is to add additional Pane Framed[ FlipView[Pane[Framed[#], 50, Alignment -> Center] & /@ {100, 1}, Alignment -> Center] , ImageSize -> {100, 150}, Alignment -> Center] But the issue is to be remembered.


1

This is not an answer. It is a suggestion about how you might simplify your code. I suggest that the simpler expression Column[{ Row[{ InputField[Dynamic @ var, Number, ImageSize -> 150], InputField[Dynamic @ unit, String, ImageSize -> 150] }], Button["Print", Print[Quantity[var, unit]]] }] will work just a well as the one you have ...


1

This accepts a plain number or "E" format or "*^" notation.. ClearAll["Global`*"]; SetAttributes[sciInput, HoldFirst]; inst[numstring_] := InputField[numstring, String, FieldSize -> {20, 1}, FieldHint -> "enter a number"]; sciInput[result_] := DynamicModule[{sig, nn}, ...


1

Problem 1 Your first problem seems to be related to a subtle bug (?) which results in a Dynamic[t] to be treated slightly different than a Dynamic[something[t]]. You can get the first button to work with either double negating the boolean as you did or by using TrueQ[t] (which might be a good idea in the sense of of defensive programming anyway). So this ...


1

There are some options to Button that let you change the way a button looks. For example, Appearance and BaseStyle. Also, you can use a Graphics object as the button label, which will give you a lot of control over appearance. See Button for more detail. In particular, look at Option > Neat Examples.


1

Original (incorrect) answer When you press in the white area and drag into the green square, you begin a selection just like when you select objects for copy-paste operations. The workaround I propose is to prevent the selection process to begin in the first place. First way: Create the cell with the option Selectable -> False ...


1

Simple InputField will work. You just need to use \[NewLine] when you need it. Create a pallete for this purpose or a shortkey, or event handler. You can use a quick fix too: InputField[ Dynamic[x, (x = StringReplace[#, "\\n" -> "\n"]) &], String, ContinuousAction -> True] so now every time you type "\n" it will create ...



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