Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Background: I want to split graphics in a Manipulate in several parts in a tabview control. But the tabview somehow interferes with the locators as in the following simplified example:

  TabView[{aa -> Graphics[Line[{{0, 0}, p}], PlotRange -> 1], 
    bb -> 1}] , {{p, {1, 1}}, Locator}]

Question: How to use Locators on a graphic in a tabview. ( How to get the snippet above working ? )


I left out too much in the previous example, this is a better description.

   pts1 = pts;
    a -> Graphics[Line[pts1]],
    b -> Graphics[Line[pts]]}],
  {{pts, ptsI}, Locator, LocatorAutoCreate -> All}, 
  Initialization -> {pts = {{0, 0.5}, {0, 0.6}}}]

So, there is one set of data, in this example pts. In one part of the display (A) the data is modified, the data is then shown on ( B ). -

share|improve this question
up vote 14 down vote accepted

Maybe something like

Manipulate[pts1 = p; pltrng = {{-1, 1}, {-1, 1}};
pnts = LocatorPane[Dynamic[p, {(pts1 = p; p = #) &, (p = #) &}],
Dynamic@Graphics[Point[p], PlotRange -> pltrng], 
LocatorAutoCreate -> True];
tbl = Dynamic[Grid[Table[With[{i = i}, {i, Dynamic[pts1[[i]]]}], {i, Length@pts1}]]];
ln = Dynamic@  Graphics[{Red, Thick, Line[pts1]}, PlotRange -> pltrng]; 
bzc = Dynamic@ Graphics[{Blue, BezierCurve[pts1]}, PlotRange -> pltrng];
dsk = Dynamic@ Graphics[{Orange, Disk[#, .1] & /@ pts1}, PlotRange -> pltrng];
plygn = Dynamic@ Graphics[{Green, Polygon[pts1]}, PlotRange -> pltrng];
allviews =  Grid[{{pnts, tbl, dsk}, {ln, bzc, plygn}}, Dividers -> {All, All}];
TabView[{"locators" -> pnts, "table" -> tbl, "line" -> ln, "beziercurve" -> bzc, 
  "disks" -> dsk, "polygon" -> plygn, "all" -> allviews}, 
Alignment -> Center], 
{{p, {{-.5, -0.5}, {-.25, .5}, {.6, 0.6}}}, None}]

enter image description here

share|improve this answer
Very nice! I think this is exactly what he had in mind. However, the LocatorAutoCreate doesn't work as expected for me... Instead of creating a new one, it simply moves the previously selected one. – R. M. May 14 '12 at 2:45
@R.M Works OK for me. Remember to press "Alt - Mouse Click" instead of just "Mouse Click" to create a Locator – Dr. belisarius May 14 '12 at 3:49
@R.M and belisarius thank you for the votes. I had to change the setting for LocatorAutoCreate to True from All in OP's question. With this setting, as belisarius notes, one needs to use Alt-Click to create a new locator. – kglr May 14 '12 at 4:24
@belisarius Ah, thanks. Cmd-click for me. Indeed, it was because of what kguler says in his comment... I tried the OP's code which had All and created locators with a simple click and tried that here too :) – R. M. May 14 '12 at 4:30
@ndroock1, glad it worked for you. – kglr May 14 '12 at 6:31

One way to get it working is to do something like

   aa -> LocatorPane[Dynamic[p], Dynamic@Graphics[Line[{{0, 0}, p}], PlotRange -> 1]], 
   bb -> 1}], 
 {{p, {1, 1}}, None}]
share|improve this answer
This one has the additional benefit of allowing the usage of Dynamic[p] on the second tab – Dr. belisarius May 13 '12 at 19:05
This works Heike, it may or may not be a solution to my problem but it definitely gives me something to study and work on. I just need a LOT of screen real estate to display graphics and manipulate it with controls. The best way to handle this is with tabs in my opinion and a lot of programs work like that. – nilo de roock May 13 '12 at 19:09
I have edited ( improved ) the question. Your solution did not work ( immediately ) but I am still working with your idea. – nilo de roock May 13 '12 at 19:34

You can move the TabView outside the Manipulate and it works:

    aa -> Manipulate[Graphics[Line[{{0, 0}, p}], PlotRange -> 2], {{p, {1, 1}}, Locator}], 
    bb -> 1}

enter image description here enter image description here

share|improve this answer
Damn ... by 10 seconds :) – Dr. belisarius May 13 '12 at 18:58
@belisarius :-D – R. M. May 13 '12 at 18:59
I have Manipulates per tabview at the moment and that causes a lot of sync problems. – nilo de roock May 13 '12 at 19:03
@ndroock1 I don't quite understand what you mean by "manipulates per tabview" – R. M. May 13 '12 at 19:04
@R.M - Like TabView[a->Manipulate[],b->Manipulate[],...] that works somewhat with an outer Manipulate but it is infact a workaround for the problem proposed in this question. – nilo de roock May 13 '12 at 20:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.