jmborr
jmborr

Reputation: 1295

How to reduce the space occupied by an ipywidget checkbox below 100px?

No matter what I do, it seems the smallest width of an ipywidgets.Checkbox is 100px. Anything smaller and the widget doesn't show. It seems a waste of space when grouping with other widgets in an ipywidgets.HBox

import ipywidgets as ipyw
ly = dict(margin='0px', border='solid', max_width='100px')
w = ipyw.Checkbox(value=True, layout=ly)
display(w)

Also the widget is right-justified by default. I didn't figure out how to change the justification.

Has anyone come up with a way to decrease the occupying space?

Upvotes: 1

Views: 2881

Answers (1)

VictorDDT
VictorDDT

Reputation: 613

There is an option "indent". Set it to "False".

from ipywidgets import HBox, Checkbox
checkbox501 = Checkbox(True, description='501', indent=False, layout=Layout(width='50px', height='50px'))
checkbox502 = Checkbox(False, description='502')
HBox([checkbox501, checkbox502], layout=Layout(width='850px', height='80px'))

enter image description here

Upvotes: 7

Related Questions