-2

I'm building an interface in Jupyter Notebook, and for one of the questions being asked (there is a VBox consisting of a Label with the value being the name of the question), users should only be able to select one of the choices. Since I am asking multiple questions, and some of the questions allow multiple answers, I am using a checkbox because I do not know how to make the vertical radio buttons have consistent spacing with the other checkboxes.

A screen shot of my UI showing a grid of checkboxes with three columns and many rows

this image gives an idea of what the layout looks like.

dbc
  • 104,963
  • 20
  • 228
  • 340
flighted
  • 11
  • 2

1 Answers1

0

You could keep the checkboxes in a list and call a function every time any of those checkboxes are changed.

For example:

def onCheckBoxChanged(event):
    widget = event['owner']
    for checkbox in groupby_checkboxes:
        if checkbox != widget:
            checkbox.value = False

groupby_checkboxes = []
for i in range(4):
    new = widgets.Checkbox(value=False)
    new.observe(onCheckBoxChanged, names=['value'])

nernac
  • 175
  • 2
  • 9