Tag Info

Hot answers tagged

7

Here's a walkaround: Manipulate[ x, Row @ List @ EventHandler[ Checkbox[Dynamic[x]], {"MouseDown" :> (x = True), "MouseUp" :> (x = False)}] ]


7

It turned out that the MathematicaClosingDialog.nb is a nice example for a graphical user interface that solely uses the FrontEnd MathKernel. On the downside, one has to deal with low-level code. First I made a copy of the original MathematicaClosingDialog.nb, renamed it as MathematicaClosingDialog_Default.nb, and then imported it into a notebook: nb = ...


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


4

Something like this? This seems to be controlled by WindowElements nb = CreateDocument[ TextCell[StringJoin[Table["abcd ", {50}]], "Text", PageWidth -> 1200], WindowElements -> {}];


3

Note the second paragraph you've cited: If the dialog contains no DefaultButton or CancelButton, pressing Enter or Esc will close the dialog without taking any other action. It turns out the inverse is true as well; you can make the dialog notebook contain an invisible DefaultButton that doesn't do anything. Here's an example with Overlay: ...


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

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

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.


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

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

Not sure if it is what you are after: action[dog_] := Print@StringForm["take dog no.`` for a walk", dog]; RadioButtonBar[Dynamic[dog, (dog = #; action[dog]) &], {1, 2, 3}]


2

I can confirm that this occurs (using the above code and clicking "panel format…") using Mathematica v.10.0.0 on OS X 10.9.4 (64-bit). I can't provide any further help on the MWE for this, as I'm still learning to use MMA as a coding language, rather than a fancy CAS. I've uploaded a copy of the OS X crash log here. EDIT: As Mr. Wizard observed, this ...


2

Dynamic is sometimes too aggressive for some purposes. You need to make sure Dynamic updates only when you are ready for new results. Besides, to ensure that Dynamic will have enough time to process your request it is sometimes a good idea to use SynchronousUpdating option. In the solotuion below you will see that instead of calculating the menu options ...


1


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

Using the logManipulator from my answer to Logarithmic slider, you can also achieve your objective via Manipulate[ f[x, y], {x, 10.^-10, 10^-1, 10, logManipulator[##] &}, {y, 0.01, 1, 0.01}] Code for logManipulator: ClearAll[logManipulator]; With[{smallerRule = {Large -> Medium, Medium -> Small, Small -> Tiny}}, ...


1

f[x_, y_] = x*y; Manipulate[ f[x, y] // ScientificForm, {{x, 10.^-6}, 10.^Range[-1, -10, -1]}, {{y, .5}, 0.01, 1, 0.01, Appearance -> "Labeled"}]


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.



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