-
Notifications
You must be signed in to change notification settings - Fork 965
Closed
Labels
Description
Description
When arranging an ipywidgets.Output widget next to another widget in an ipywidgets.HBox, the Output widget will take too much space. In the most extreme case, where you put an ipywidgets.VBox next to the Output widget, the contents of the VBox will even shrink to 0 width.
In the following screenshot, you see three examples:
- Example where HBox/VBox layout works as expected. It only arranges
ipywidgets.Dropdownandipywidgets.Selectwidgets, and no Output widgets. - Example where a Select widget is next to an Output widget in an HBox, and the Select widget is shrinked even though it should have a fixed width (because the
widthparameter is set). - Example where a VBox is next to an Output widget and the Output widget consumes all the horizontal space so that the contents of the VBox are not visible at all.
Complete code (for copy-pasting)
import ipywidgets as widgets
w_select = widgets.Select(options=["abc", "def", "asdf"])
w_select.layout.width = "58ex"
w_dropdown = widgets.Dropdown(options=["a", "b"])
w_output = widgets.Output()
with w_output:
print("asjdalhsd")
display(
widgets.HBox([
widgets.VBox([
w_dropdown,
w_select,
]),
widgets.Select(options=["0123", "847", "92828"]),
])
)
display(
widgets.HBox([
w_select,
w_output,
])
)
display(
widgets.HBox([
widgets.VBox([
w_dropdown,
w_select,
]),
w_output,
])
)Reproduce
- Open a Jupyter Lab instance.
- Create a new notebook.
- Copy the code (see above) into the notebook.
- Execute the whole notebook.
- Observe that, in the last example, the Dropdown and Select widgets are not visible.
Expected behavior
The Dropdown and Select widgets should be visible next to the Output widget, just as in the first example.
Context
- ipywidgets version 8.1.0
- Operating System and version: Ubuntu 22.04.3, but the problem persists on other machines
- Browser and version: tested with Firefox 116.0.2, and Chromium 115.0.5790.110
Troubleshoot Output
Post gets too long. Please ask again if you really need this.
Command Line Output
Post gets too long. Please ask again if you really need this.
Browser Output
Post gets too long. Please ask again if you really need this.
If using JupyterLab
- JupyterLab version: 4.0.4
Installed Labextensions
JupyterLab v4.0.4
/home/tovogt/.local/share/miniconda3/envs/ipywidgets-test/share/jupyter/labextensions
jupyterlab_pygments v0.2.2 enabled X (python, jupyterlab_pygments)
@jupyter-widgets/jupyterlab-manager v5.0.8 enabled OK (python, jupyterlab_widgets)
The following extensions are outdated:
jupyterlab_pygments
Consider checking if an update is available for these packages.
jmeyers314 and JoepVanlier
