I am creating a GUI for an application which presents a grid of check boxes. The user can check a box to display a specific part of a graphics image. The following is a simple version of a more complex interface:

line1 = CheckboxBar[{1, 3}, {1 -> "1", 2 -> "2", 3 -> "3"}]
line2 = CheckboxBar[{1, 5}, {1 -> "{A,B}", 2 -> "{C}"}]
mygrid = {};
mygrid = Append[mygrid, {line1}];
mygrid = Append[mygrid, {line2}];

This would present check boxes with labels like:


The graphics includes links between the rows of check boxes and I would like to identify these links with arrows. For example, I could have a link from 3 on the first row to the {C} on the second row. Would be very informative if I could include an arrow in the grid from from any check box in row $i$ to any check box in row $i+1$. For example could I draw an arrow from 3 to {C}?

Or could you guys suggest another interface I could effect this design?

  • 1
    $\begingroup$ What you specifically ask for: drawing arrows between cells in Grid construct is beyond my abilities, but I can't categorically say it is impossible. However, I do not recommend trying to go down that path. There are two possibilities that I think are much more feasible: 1) use graphs and GraphPlot, 2) use Inset (to hold the check boxes) and Graphics. $\endgroup$ – m_goldberg Apr 1 '17 at 22:29
  • $\begingroup$ @Dominic, One seldom needs to Append a vector or array in Mathematica. Your code would give the same result if skipped 'mygrid' and used Grid[{{line1}, {line2}}]. $\endgroup$ – Ted Ersek May 2 '17 at 0:58

Ok thanks. I think I can use something like:

g1 = Graphics[{Inset[Checkbox[True], {0, 5}], Text["{1,2}", {0.5, 5}],
 Inset[Checkbox[True], {2, 5}], Text["{3}", {2.5, 5}]}];
g2 = Graphics[{Inset[Checkbox[True], {0, 4}], Text["{3}", {0.5, 4}], 
Inset[Checkbox[True], {2, 4}], Text["{2}", {2.5, 4}]}];
a1 = Graphics[Arrow[{{0, 4.8}, {0, 4.2}}]];
Show[{g1, g2, a1}, PlotRange -> {{-1, 6}, {-1, 6}}] 

That draws an arrow from checkbox {1,2} on the first row to checkbox {3} on the second. And I assume I can use the same interface I'm using to retrieve all the (dynamic) check mark data. And also this way I have better control of placement of all the data in the GUI.

| improve this answer | |
  • $\begingroup$ I'd recommend to use ImageSize->{120, 70} instead of PlotRange. $\endgroup$ – garej Jun 1 '17 at 5:48
 {Button["1"] -> Button["A"], 
  Button["2"] -> Button["B"], 
  Button["3"] -> Button["C"]},
 DirectedEdges -> True,
 VertexRenderingFunction -> ({EdgeForm[Black], Yellow, Disk[#1, 0.15],
      Black, Text[#2, #1]} &)]
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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