Tag Info

Hot answers tagged

47

Since Mathematica does not have a built-in plot manipulating interface, here is a gui of a plot-manipulator. Updates are indicated with bold text. Functionality: Should work with any plot/graphics (ArrayPlot compatibility added); Drag anywhere in plot zooms in to selected rectangle; can be done repeatedly; Ctrl+drag zooms in/out (along vertical axis); ...


17

In addition to István's fine answer, there is also Experimental`Explore[] which provides almost all the functionalities in his PlotExplorer. I think it was Szabolcs who first told me of this function. If you call the above function with no arguments, you can choose to interactively work with either Plot, ParametricPlot, Manipulate or Graphics. Alternately, ...


13

I'll post a function based on the title of the question. You wrap your dynamic code in profileDynamics optionally passing the option "Print"->True (defaults to False). It should be noted that this can only profile the explicit Dynamics that are on the code. Nested dynamics that are generated at runtime are not profiled by this ClearAll[profileDynamics]; ...


12

This solution relies on putting a TagBox with a custom tag around the part to be replaced, reading the cell and replacing the tag, then writing it back. Personally I've always felt that the need to read the entire cell and write it all again seems kind of clunky, but I don't know of a better way to do this. ...


10

Like this Slider[Dynamic[y,(y=#;f[y])&],{1,4}] You can can test using for example f[y_]:=Print@y; I advise you to look at the help of Dynamic that contains examples of other related features.


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


8

You can use the "wormhole" construct from "tutorial/AdvancedDynamicFunctionality" like this: Manipulate[ Graphics[ Translate[ GeometricTransformation[{Blue, Polygon[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}]}, {{scx, 0}, {0, scy}}], Tuples[{Range[wi], Range[he]}] - 1], ImageSize -> 400 {1, 1}], OpenerView[{Button["external", ...


8

If you notice Mathematica Documentation Center search field is kind of the same thing. And search window from Ctrl-F too. It uses a similar concept to what I'll show. Important thing to know is that EventHandler can track commands from the Mathematica menu. There is an undocumented option HandleShiftReturn and here is a trick I learned from FW: ...


8

First, define PopupView with empty reference list and only substitute real reference list ref into the PopupView if it is first clicked. This is done by wrapping the PopupView in an EventHandler. The dynamically displayed list next to the initially empty PopupView shows that before clicking, it is empty, and only gains its value when first clicked. ...


7

The behaviour is indeed inconsistent: CreateDialog uses the option WindowSize -> All, where All (god knows why) causes the unexpected behaviour with dynamic content. See resolution of the problem at the end of the post. The following even more simple example clearly shows that something fishy is going on: only path2 can be set via the second button but ...


7

AFAIK there is no possiblity to react to the OS drag & drop, but I would'nt be surprised if someone has found a way to get that work. Anyway, the following is roughly what I'd do: guidefinition = Deploy@Panel@DynamicModule[{ num1 = 100, num2 = 10, path = FileNameJoin[{$HomeDirectory, "Desktop", "file.xls"}], year = Null, month = Null, ...


7

Assign your input in DialogReturn, e.g. to a variable return. Apart from from this, and omitting your Dynamic@x at the end, your code is unchanged: DynamicForm[row_, col_] := DynamicModule[{x = ConstantArray[0, {row, col}], a}, a = {Column[(Row[#] & /@ Table[With[{i = i, j = j}, InputField[Dynamic[x[[i, j]]], Number, ...


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


7

You could always try a gauge: gf[{{xmin_, xmax_}, {ymin_, ymax_}}, ___] := {Black, Rectangle[{xmin, -0.01}, {xmax, 0.01}, RoundingRadius -> .01]} HorizontalGauge[Dynamic[n], {1, 9}, ScaleDivisions -> None, ScaleRanges -> All, ScaleRangeStyle -> None, GaugeFaceElementFunction -> gf, GaugeMarkers -> Placed[ Graphics[{Black, ...


7

If pre-version-9 (no gauges yet), one has to rely on custom built controllers. Here is a slider implementation using LocatorPane (I prefer lines with rounded caps instead of rectangles because of aspect ratio issues): slider[Dynamic[var_], {min_, max_}] := Module[{x = 0}, LocatorPane[ Dynamic[{x, 0}, (x = First@#; var = Rescale[x, {-1, 1}, {min, ...


6

I suspect there might be an easier way to do this, but you might use a variation of this example: Module[{nb}, Button["Find and run",( path1 = SystemDialogInput["FileOpen"]; nb = NotebookOpen[path1, Visible -> False]; SelectionMove[nb, All, Notebook]; SelectionEvaluate[nb]; NotebookClose[nb]; )]] Update: I initially couldn't get ...


6

Sure. Just replace TextCell["profile starts at x =", FontSize -> 16, TextAlignment -> Right] With Dynamic[TextCell["profile starts at" <> ToString[direction] <> " =", FontSize -> 16, TextAlignment -> Right]] and TextCell["measurement starts at y =", FontSize -> 16, TextAlignment -> Right] by ...


6

Some generic examples: DynamicModule[{var = 3, var2 = 1, var3 = "hello"}, Column[{ PopupMenu[ Dynamic[var], {1 -> "Display Popup", 2 -> "Display Input field", 3 -> "None"}], PaneSelector[{ 1 -> PopupMenu[Dynamic[var2], Range[4]], 2 -> InputField[Dynamic[var3]], 3 -> Spacer[0] }, Dynamic[var]] }] ...


6

I think these questions being indeed basic, are rather important. I cannot answer the first two myself, though would love to see some methods that can deal with them. As always, there are other ways to solve the remaining two questions. Since Mathematica is not designed to produce standalone ("executable") files, you need to have either Mathematica or the ...


6

ExpressionCell[Panel@DynamicModule[{input = ""}, InputField[Dynamic[input], String]]] Content added: ShiftReturn pressed: Learned this here.


6

Here's one way to do it. In this example I've used one list of points for the vertices of the two shapes. The inner EventHandler sets the flag drag which indicates which shape should be moved. The outer EventHandler actually moves the shape. Releasing the mouse resets drag to 0 again. I'm using PassEventsDown -> True in the outer event handlers to make ...


6

If you want the evaluation to halt until the Dialog returns you can get your code working very simply: DynamicForm[row_, col_] := DialogInput[{x = ConstantArray[0, {row, col}], a}, Column[Flatten@{{Column[(Row[#] & /@ Table[With[{i = i, j = j}, InputField[Dynamic[x[[i, j]]], Number, FieldSize -> Tiny]], {i, 1, row}, {j, 1, ...


5

The simplest that comes to mind is to close it before opening it again. So, where you had the CreateDialog[...] line, you now put NotebookClose[nb]; nb=CreateDialog[...] (You can wrap your button in DynamicModule[{nb}, Button[...] to localize the symbol) A better one, is to put If[FreeQ[Notebooks[], nb], nb=CreateDialog[...]] Here's the tweaked code ...


5

Something like this? scx = scy = wi = he = 1; CreateDocument@ Dynamic@Graphics[ Translate[ GeometricTransformation[{Blue, Polygon[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}]}, {{scx, 0}, {0, scy}}], Tuples[{Range[wi], Range[he]}] - 1], ImageSize -> 400 {1, 1}]; CreatePalette[ Grid[ { {"x scale", Slider[Dynamic[scx], {0, ...


5

Does this provide the functionality you are looking for? Note that a multi-selectable SetterBar is a TogglerBar. The only problem with the latter is that it cannot be partitioned into a multi-row grid. For your particular problem, I would rather use Button instead of Setter: list = {}; Dynamic@list Grid[Table[ DynamicModule[{pressed = False}, With[{idx ...


5

If you only want to remove one button, the solution is easy: list = {Button[1], Button[2, list = Delete[list, 2]], Button[3]}; Dynamic@list If you want to remove multiple unique buttons, you have to use some kind of identification for each button other than the actual position in the list, as that is changed when one of them is removed. Here I use a ...


5

I don't think that GUIKit is mentioned in cdf-faq or in details for programmers, presumably because it is considered obsolete as Sjoerd has mentioned. From the restrictions that are mentioned there (no JLink, no alternative FrontEnds) I would conclude that it isn't supported, although I haven't actually tried whether it works. There are possibilities to get ...


4

You could use FileNameSetter which seems a better choice for setting the path. If you have a DynamicWrapper containing your function call, it will be run every time the path is changed. When the user cancels, the path doesn't change, so it won't trigger anything or require special handling. Here I just use a dummy work function which prints the chosen files ...


4

One can come up with some messy method to evaluate a front-end button programmatically, but I think it is easier to separate the button functionality from the button itself, as listenerButtonFunction[]. Here I introduce a timer button that, if pushed, counts down simulating a long calculation. When it finishes, it switches the flag active to True. The second ...


4

You want to use PopupMenu: PopupMenu[a, {a, b, c, d}] Note, if you want it to be dynamically linked to a variable, use: PopupMenu[Dynamic[x], {a, b, c, d}] Then, x takes the value given by the drop down menu:



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