Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output widget expands too aggressively in HBox #3822

Closed
tovogt opened this issue Aug 9, 2023 · 3 comments
Closed

Output widget expands too aggressively in HBox #3822

tovogt opened this issue Aug 9, 2023 · 3 comments

Comments

@tovogt
Copy link

tovogt commented Aug 9, 2023

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:

  1. Example where HBox/VBox layout works as expected. It only arranges ipywidgets.Dropdown and ipywidgets.Select widgets, and no Output widgets.
  2. 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 width parameter is set).
  3. 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.

image

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

  1. Open a Jupyter Lab instance.
  2. Create a new notebook.
  3. Copy the code (see above) into the notebook.
  4. Execute the whole notebook.
  5. 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.

@TorbjornWidhe
Copy link

TorbjornWidhe commented Sep 21, 2023

I have the same problem and found a workaround until this is fixed

w_output.layout.width = '50%' # Control the width of the output widget manually
display(
    widgets.HBox([
        widgets.VBox([
            w_dropdown,
            w_select,
        ]),
        w_output,
    ])
)

@fleming79
Copy link

I think this might have been fixed in the latest Jupyterlab release 4.0.7 with the horizontal scrolling fix.

@tovogt
Copy link
Author

tovogt commented Oct 16, 2023

Yes, I can confirm that this issue is fixed in 4.0.7. Thanks for the feedback!

@tovogt tovogt closed this as completed Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants