ipywidgets
ipywidgets copied to clipboard
Output widget doesn't display horizontal scroll even after setting layout.overflow
Description
Can't create horizontal scroll on Output widget.
Using in a scenario similar to #3184, but with matplotlib (ipympl).
- It seems like there's an HTML Element between the output widget and the output that sets
overflow: hidden
in the CSS, overriding with auto makes the scrollbar visible - I have managed to create the desired effect in a Box
Reproduce
- clean install jupyterlab ipywidgets
I am not using anaconda - so
1.1. new venv
1.2. activate venv
1.3.
python -m pip install -U pip
1.4.python -m pip install -U setuptools
1.5.python -m pip install -U jupyterlab
1.6.python -m pip install -U ipywidgets
- Create some widget/s
- Display the widgets in an Output widget with shorter width
- Open inspector and find the output widget.
<div class="lm-Widget p-Widget lm-Panel p-Panel jupyter-widgets widget-output" style="overflow: visible; width: 200px">
<div class="lm-Widget p-Widget jp-OutputArea">
<div class="lm-Widget p-Widget lm-Panel p-Panel jp-OutputArea-child">
<div class="lm-Widget p-Widget jp-OutputPrompt jp-OutputArea-prompt"></div>
<div class="
lm-Widget
p-Widget
lm-Panel
p-Panel
jupyter-widgets
jp-OutputArea-output
">
<div class="
lm-Widget
p-Widget
lm-Panel
p-Panel
jupyter-widgets
widget-container widget-box widget-hbox
" style="display: flex; flex: 1 0 auto">
<button class="
lm-Widget
p-Widget
jupyter-widgets jupyter-button
widget-button
" title="" style="width: 300px"></button><button class="
lm-Widget
p-Widget
jupyter-widgets jupyter-button
widget-button
" title="" style="width: 300px"></button>
</div>
</div>
</div>
</div>
</div>
- Note the div with the class: jp-OutputArea-child has
visible:hidden
overriding for this div withoverflow: auto
fixes the problem Note: the first div has the inline style defined using the code below:
Code:
import ipywidgets as wg
btn_a = wg.Button(layout=wg.Layout(width="300px"))
btn_b = wg.Button(layout=wg.Layout(width="300px"))
res = wg.Box([btn_a, btn_b], layout=wg.Layout(flex="1 0 auto",
display="flex",
width="300px"))
out = wg.Output(layout=wg.Layout(
width="200px",
overflow="visible"))
with out:
display(res)
out
Expected behavior
The Output widget should display a scrollbar when its content is larger than itself
Context
- ipywidgets version 7.6.5
- Operating System and version: Win10
- Browser and version: Chrom 95.0.4638.69
If using JupyterLab
- JupyterLab version: 3.2.4
Installed Labextensions
JupyterLab v3.2.4 @jupyter-widgets/jupyterlab-manager v3.0.1 enabled ok (python, jupyterlab_widgets)
Workaround
import ipywidgets as wg
btn_a = wg.Button(layout=wg.Layout(width="300px"))
btn_b = wg.Button(layout=wg.Layout(width="300px"))
res = wg.Box([btn_a, btn_b], layout=wg.Layout(flex="1 0 auto",
display="flex",
width="300px"))
box = wg.Box(layout=dict(display="flex", width="200px"))
box.children = [res]
box
Screenshot
Output:
In case it helps, I think this is fixed in ipwidgets==8.0.0b0
(or any of the other 8.x
pre-releases) due to https://github.com/jupyter-widgets/ipywidgets/pull/2500, or you can try building ipywidgets
with the fix locally following something like this.
In case it helps, I think this is fixed in
ipwidgets==8.0.0b0
(or any of the other8.x
pre-releases) due to #2500, or you can try buildingipywidgets
with the fix locally following something like this.
Confirming that this fixes the issue. thx!
With 8.x released, I'm closing this as resolved.