4

I create an IntText widget like this:

import ipywidgets as widgets
widgets.IntText(value=12, 
       description='CTR1_0', 
       style={'description_width': 'initial'})

When I include this widget in an HBox in a Tab, the text box is much larger than I need. How do I set it to be 10 characters?

enter image description here

There is no width parameter to IntText. I have tried adding width="10ch" to the style parameter do not work.

Lars Ericson
  • 1,952
  • 4
  • 32
  • 45

1 Answers1

9

Create a Layout when you instantiate the button, and pass it as a layout= kwarg. You can hard code a pixel size, but probably not a character limit.

import ipywidgets as widgets
w = widgets.IntText(value=12, 
       description='CTR1_0', 
       style={'description_width': 'initial'},
       layout = widgets.Layout(width='100px')
)
# w.layout = widgets.Layout(width='100px')   # or set it later

ac24
  • 5,325
  • 1
  • 16
  • 31