Tag Info

Hot answers tagged

75

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


25

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


23

One of the excellent places to look is the Wolfram Demonstration Project. There are many cases with custom controls there. You can test out controls immediately and download the source code. Because I know that site pretty well I will keep the list here. Relief-Shaded Elevation Map 3D Waves Potter's Wheel Motion Blur Contours of Algebraic ...


15

You could do create a simple graph editing tool to create a graph from scratch by doing something like this. To add edges you just click and drag. DynamicModule[{pt1, pt2, ind1, ind2, pts = {}, edges = {}, cedge = {}}, Manipulate[ EventHandler[ Dynamic@Graphics[ {Line[pts[[#]] & /@ edges], cedge, {Red, PointSize[Medium], Point[pts]}}, ...


15

Some you can find in the Documentation Center, like the angular slider in Dynamic's documentation (under Applications), or the ValueThumbSlider in the Advanced Manipulate Functionality section (under Custom Control Appearances). Some you can find in developer packages like the angular slider in the "Experimental`" package: Needs@"Experimental`"; ...


14

You want to use Grid. Code Panel[ Grid[ { (* The 1st row *) { Row[{"Board size: ", InputField[Dynamic[max], Number, FieldSize -> 3]}], Button["Clear Board", ImageSize -> All] }, (* The 2nd row *) { Graphics[Circle[], ImageSize -> 300], SpanFromLeft } }, Alignment -> {{Left, Right}, Baseline}] ] ...


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

Since Input is a DialogInput, it seemed reasonable to peek into Input's structure to understand how the focus is set. After removing the ReadProtected attribute I've realized that there is no neat way to do it, as WRI itself has done the reposition of the focus via successive SelectionMove calls. This example below is not the original but a modified ...


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


12

This is a bit more complicated, but I did this for a human experiment previously, so why not share it. The code keeps track of nodes and edges of a graph that can be manipulated: new edges can be drawn by dragging the mouse from one node to the other edges can be deleted via right-click menu nodes can be moved by dragging while holding Ctrl node can be ...


11

Try: Button["Select this cell", SelectionMove[ButtonNotebook[], All, EvaluationCell]]


10

You can use a combination of MouseDown and MouseClickCount as in the following examples: example 1: double-click increments the value of j: j = 1; EventHandler[Panel[Dynamic[j]], "MouseDown" :> If[CurrentValue["MouseClickCount"] == 2, ++j]] example 2: double-click toggles the text color: DynamicModule[{col = Green}, EventHandler[ ...


10

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


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

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


9

This solution illustrates using Spacer. Move the slider to place the button anywhere you want along the width of interface: Manipulate[Panel[Column[{Row[{"Board size: ",InputField[Dynamic[max], Number, FieldSize -> 3], Spacer[spacer], Button["Clear Board"]}], Plot[Sin[x], {x, -3, 3}, ImageSize -> 400]}]], {{spacer, 100}, 0, 220}, FrameMargins -> ...


9

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


9

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


9

You can also look at the GUIKit` package which allows you to create complicated widgets and panels that mimic the look and feel of the OS. The user guide/tutorial is pretty decent and has several examples too that you can learn from and modify to your needs. In fact, a lot of the additional editing/explorer functionality like GraphEdit and DatabaseExplorer ...


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

Let's see if now I got it better... DynamicModule[{var = False}, Dynamic@Column[{PopupMenu[ Dynamic[var], {False -> #, True -> "Add another Menu"}], If[var, #0["new menu"], ## &[]]}]] &["one menu"]


8

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


8

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


8

First, let me note that 50kB for such a simple graphics is unbelievably much. In fact, I had to create large and randomized raster icons to achieve such a size. Your things on the other hand look really simple and should be extremely small as vector-graphics. So here is what I tried: n = 200; MapIndexed[Export[StringJoin["tmp/", ToString[#2[[1]]], ".pdf"], ...


8

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


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


7

Not 100% solution, but this may work. Define: dialog := CreateDialog[{TextCell["Click OK to close"], DefaultButton[]}, Modal -> True, NotebookEventActions -> {"WindowClose" :> dialog}] Then call: dialog At least, it reappears :)


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

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


7

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



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