Tag Info

Hot answers tagged

5

Update. Thanks to Eldo, Dynamic is needed outside the InputField. DynamicModule[{a = 1, b = 20, fuc = "1"}, Deploy[Style[Panel[Grid[Transpose[ { {"Input Format", "Value"}, {PopupMenu[Dynamic[fuc], {"1", "2"}], Dynamic@InputField[ If[fuc == "1", a, b], Number, Enabled -> Dynamic[fuc == "1"] ...


4

Modifying last example in Manipulate>Neat Examples (also the second example in this answer): Manipulate[ ArrayPlot[Take[data, n, n]], {{data, RandomInteger[{0, 1}, {20, 20}]}, ControlType -> None}, {{n, 5}, 1, 20, 1}, Dynamic[ Panel[Grid[Outer[Checkbox[Dynamic[data[[#1, #2]]], {0, 1}] &, Range[n], Range[n]]]]]]


3

Kuba's answer is brilliant, but it has a rather ugly bit in it with a lot of unnecessary fooling around with Hold and ReleaseHold in order to make assignment to variables. As is so often the case with Mathematica, this fooling around with variables can be eliminated by working with a list, so I have reworked Kuba's answer to keep the vertex coordinates in a ...


3

Here are two ways. One of them may be what the OP alluded to in a comment; in any case, I'll give a complete solution below. First, using If inside one InputField: The trick here is to use the second argument of Dynamic. DynamicModule[{a = 1, b = 20, fuc = "1"}, Deploy[Style[ Panel[Grid[ Transpose[{{"Input Format", "Value"}, ...


3

When a Symbol is "tracked" it means that when its value changes the Dynamic expression is refreshed, therefore your input updates as fast as possible because every refresh changes the value of t which causes a refresh which... you get the picture. Compare: Clear[t]; t = 1; Dynamic[Refresh[t++, UpdateInterval -> 1, TrackedSymbols -> {}]]


3

Something like that? list = Range[0, 9]; DynamicModule[{nr, val}, Column[{ Dynamic@list, Dynamic@list[[ nr]], Slider[Dynamic@nr, {1, 10, 1}], Slider[Dynamic[list[[ nr]]], {0, 10, 1}] }] ] Manipulate version: list = Range[0, 9]; Manipulate[ Column[{list, list[[nr]]}], Column[{ Control[{{nr, 1}, 1, 10, 1}], ...


2

This is a rough idea you can build up on. Manipulate[ Graphics[{Text[Text1, {-4, 1}], Text[Text2, {-4, 3}], Text[Text3, {-4, 5}], Text["10^-6", {4, 2}], {Line[{{1.5, 2}, {3.4, 2}}]}, {Line[{{2.5, 4}, {3.4, 4}}]}, Text["10^-3", {4, 4}], {Green, Polygon[{{{0, 0}, {-1, 2}, {1, 2}}}]}, {Orange, Polygon[{{-1, 2}, {-2, 4}, {2, 4}, {1, ...


2

EDIT: I decided this was simple enough a question that this should have more controls to make it an answer and not a comment. Manipulate[Pane[Grid[Partition[ConstantArray[1, {elems}], cols, cols, 1, ""], Frame -> All], {200, 100}, Scrollbars -> {horizScroll, vertScroll}], {{elems, 5, "Elements"}, 5, 100, 1}, {{cols, 4, "Columns"}, 4, 20, 1}, ...


2

shape1 := Graphics[{#, Circle[{0, 0}, 1.5], Disk[]}, ImageSize -> 10] &; shape2 := Graphics[{Lighter@#, Disk[]}, ImageSize -> 10] &; ClearAll[lOF]; lOF[nOfOverlays_, colors_List, opts : OptionsPattern[]] := DynamicModule[{layer = 1, pts = ConstantArray[{{100, 100}, {700, 700}}, nOfOverlays], col = ...


2

simple version With a single codeline, ColorData["Atoms", "Panel"], can be transformed in a click panel for ElementData[]. {ColorData["Atoms", "Panel"] // ReplaceAll[#, RuleDelayed[ "MouseClicked", $_] :> (RuleDelayed["MouseClicked", atomClicked = Part[RuleDelayed["MouseClicked", $], 2, 2, 2, 1, 1, 1]])] &, Dynamic[atomClicked, Initialization :> ...


1

This is only a partial answer but may help. See here for related case, it is probable that KeyDown "a" is reserved like "c". This does not work: DynamicModule[{someList = {}}, EventHandler[Graphics[{Blue, Disk[]}, ImageSize -> 100], {{"KeyDown", "a"} :> (AppendTo[someList, 1]; Print[someList])}]] (** doesn't work **) But changing "a" to ...


1

Refresh only sets a limit on how long expression can go without being updated. To keep t form being updated more often add a pause. t = 1; Dynamic[Refresh[Pause[1]; t++, UpdateInterval -> 1, TrackedSymbols :> {t}]] or do what Mr.Wizard indicated, which is better. But this sort of thing is best done by higher level constructs such as Clock or ...


1

I believe the jump in value of asd happens because you're dragging the indicator with the mouse when the range is reset. Here is a way that does what you want, I think. It interrupts the mouse-dragging by creating a new Slider when the boundary is reached. {Dynamic@asd, Dynamic@Slider[Dynamic[asd], Which[asd < 10, {1, 10}, asd >= 10, {9, 50, ...


1

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

Edit: In order to set initial values in a dynamical system one has to use DynamicModule. Anyway, if you now change slightly your code in the following way: Slider[Dynamic[n], {0, 5}] DynamicModule[{p1 = 200}, Dynamic[Plot[n (x - n)^2, {x, 0, 5}, ImageSize -> Dynamic[p1]]]] the image should remember its size.


1

I'd say it's a bug worth reporting. In the meantime you can work around it using Refresh. Perhaps something like the following Unprotect[RegionNearestFunction]; Module[{inside}, rnf : _RegionNearestFunction[___] /; ! TrueQ[inside] := Block[{inside = True}, Refresh[rnf, None]] ] Protect[RegionNearestFunction];


1

One potential solution to this would be using PreemptProtect to prevent interruption. For the example from the main question, PreemptProtect@Block[{x}, Pause[5]]


1

Finally, I discovered that the combined program works fine as long as the dragging just begin from the point close to the node (not right on the top of it). Thanks.



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