Ask Your Question
1

row of multiple selection checkboxes

asked 2020-09-26 09:08:36 -0600

rrogers gravatar image

I would like to have the multiple selection checkboxes below in a row instead of a column. I did search around and didn't come up with anything obvious. As well as knowing how to do it; what resource should I have looked at?
I am putting together anatomical diagrams of the Kerr_Schild metric.

@interact def _(red_ring =('red ring', True),
  black_ring =('black ring',False),
  green_ring = ('green ring',False)
  ):
  a = sphere((1,0,0),0.2)
  if red_ring:
    a += circle((0,0,0), 2, color='red', thickness=6)
  if black_ring:
    a += circle((0,0,0), .4, color='black', thickness=6)
  if green_ring:
    a += circle((0,0,0), .7, color='green', thickness=6)
  show(a,viewer='threejs')
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2020-10-08 15:40:27 -0600

rrogers gravatar image

updated 2020-10-08 16:49:14 -0600

This format works but I am having a small problem with "f()" argument passing, I can't seem to make it a dummy argument. The ipywidgets page that has instructions and examples is: https://www.kaggle.com/atorabi/intro-...

import ipywidgets
red_ring =ipywidgets.Checkbox(True,description='red ring')
black_ring =ipywidgets.Checkbox(True,description='black ring')
green_ring =ipywidgets.Checkbox(True,description='green ring')
ui = ipywidgets.HBox([red_ring,black_ring,green_ring])
def f(red_ring,black_ring,green_ring): 
    a = sphere((1,0,0),0.2)
    if red_ring:
         a += circle((0,0,0), 2, color='red', thickness=6)
    if black_ring:
         a += circle((0,0,0), .4, color='black', thickness=6)
    if green_ring:
         a += circle((0,0,0), .7, color='green', thickness=6)
    show(a,viewer='threejs')
out = ipywidgets.interactive_output(f, {'red_ring': red_ring,
                                    'black_ring': black_ring,
                                    'green_ring': green_ring})
display(ui, out)
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-09-26 09:08:36 -0600

Seen: 39 times

Last updated: Oct 08