# how can I create a ButtonBar for following specific actions

I have two sets of parameters p1[i] and p2[i], (i=ag, cs, wh) for which I want to create two separate button bars. I have the following conditions:

Given two equations:

 Manipulate[
...
gr[i]=xx*p1[i];
mu[i]=yy*p2[i];
p1[i]={0,1};
p2[i]={0,1};
...
]


Define a scenario such as: {p1[ag]=1, p1[cs]=1, p1[wh]=0} and {p2[ag]=1, p2[cs]=0, p2[wh]=0}. Underneath each buton I like to see the choice: 0 or 1. If it starts with 0, then clicking on the button should turn it to 1 and vice versa.

With this button format, I want to follow the parameter choices made (i.e., the type of scenario) and obtain the associated values of the two equations, gr[i], mu[i]. I want to do this using Manipulate.

For me, it is important to see the choices {0,1} made underneath each button as it will help me see the parameter choices.

I hope my explanation is clear enough.

UPDATE

For better visualizing the design of ButtonBar I wanted, I like to give the picture of the design:

For parameter set p1[i] I have three choices and the same for p2[i]. I should be clicking on the values {0,1} and the clicked ones should turn to "Green". Note that ag, cs, wh remain unchanged for both parameters.

This shows how to lay out a table of buttons that show their values and which of the values is currently set. It also shows a second table which displays the results of changing parameter values with the buttons. I use TableForm to do the layout because it's easy to use and adequate for purposes of answering this question. You can get a fancier and better looking layout if you are willing mess around with Grid.

btnLbl = SetterBar[#, {0, 1}] &;

With[{xx = π, yy = E},
DynamicModule[{tags, gr, mu, p1, p2},
gr[i_] := xx p1[i];
mu[i_] := yy p2[i];
tags = {ag, cs, wh};
Set[p1[#], 0] & /@ tags;
Set[p2[#], 0] & /@ tags;
Column[
{Dynamic[
TableForm[
{Button[btnLbl[p1[#]], p1[#] = Mod[p1[#] + 1, 2],
Appearance -> None] & /@ tags,
Button[btnLbl[p2[#]], p2[#] = Mod[p2[#] + 1, 2],
Appearance -> None] & /@ tags},
TableHeadings -> {{"p1", "p2"}, tags}]],
Spacer[36],
Dynamic[
TableForm[{{gr /@ tags, mu /@ tags},
TableHeadings -> {{"gr", "mu"}, tags}]]}]]]


• Very nice. With the separate table forms, the buttons look even nicer. Commented Nov 20, 2019 at 20:06
• In my version of Mathematica 11, I cannot see the blue colored buttons. Is there a way to set Green color manually? Commented Nov 20, 2019 at 20:21
• @TugrulTemel. As far as I know the color is set by the operating system. I run Mathematica on MacOS where the highlight color is controlled by a setting in System Preferences > General > Appearance. The choices are Blue and Graphite. Commented Nov 20, 2019 at 20:34
• Your above answer solved the question. Since my problem was much wider than what my question implies, I tried to solve the rest of my problem by myself by playing around your Code. However, I failed to solve my problem. The rest of my problem is not worth to ask a new question because it is just one step away from the answer. Would it be appropriate for me to update my question again for an extension to your Code? I would appreciate if you guide me. thanks. Commented Nov 21, 2019 at 22:17
• @TugrulTemel. Yes, it would be entirely appropriate for you to add an update to question to seek further assistance. I do ask that you insert the code you are working with, so I and others can see how you modified my code. Please insert the code in a form that can be copied and pasted into Mathematica, so that others can use it as a basis for experiments. Commented Nov 22, 2019 at 0:21