-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Redrawing Results Incorrect #7354
Comments
Yes, if I recall what the underlying issue is, this is a known issue with widgets and Jupyter - closing a widget does not actually remove the underlying DOM node or message from the notebook outputs. The key issue here is that a notebook output cannot delete itself, only the user can delete a notebook output by clearing the output. Some would consider that a feature... |
One thing is that a DOM node remains, a separate issue is that such empty nodes take up space. A possible solution is to add a CSS rule using e.g. |
This is also discussed at jupyter-widgets/ipywidgets#1845 |
I'm in favour of @vidartf's suggestion followed by the creation of an issue to discuss whether to deal with it in a more proper manner. This would remove the annoyance that several users are experiencing, while not just shoving it under the carpet. |
While we're still waiting for a code change, is there a temporary solution to fix the problem? I tried to add a CSS rule as suggested in bstriner/keras-tqdm#21 and all similar approaches, but none of them work with jupyterlab. I figured out that the div names are indeed different for jupyterlab, and the culpable one here is |
I just checked. In JLab, the output area after a widget is closed is not actually an empty div, just a hidden div, and there are several layers of padding. I didn't see an obvious selector. In general, there are no CSS selectors for parents of items having particular properties. |
Are there any steps we can reasonably take to make it "more empty", or maybe add a CSS class to indicate a closed widget? If that is the case, then maybe someone could do a PR adding such a class? |
There are two aspects at play here, from what I can see with my rudimentary HTML/CSS knowledge.
Fixing 1 should be easy: jp-OutputArea-prompt:empty {
padding: 0;
border: 0;
} I played around with this in jupyterlab by calling the following in a markdown cell, and couldn't find any problems with it. from IPython import HTML
HTML("""
<style>
.jp-OutputArea-prompt:empty {
padding: 0;
border: 0;
}
</style>
""") I'm happy to submit a PR on this, but I tried installing a developer version of jupyterlab, and I'm currently getting a error when running |
@thomasaarholt would you mind PR'ing the fix? The extra whitespace is killing me... |
This issue is 2 years old now 🎂 Jupyter-Lab v3.2.1 still has this issue. |
@thom Thank you, this partial workaround is still possible with from IPython.core.display import HTML
HTML("<style>.jp-OutputArea-prompt:empty {padding: 0; border: 0;}</style>") However, after some point Jupyter cuts the output (it seems to think too many lines have been drawn), and it doesn't recover the nested bar when clicking on the message. |
This did help with the issue but on Jupyterlab it still moves the inner progress bar, even though it is much less. Here is my code import time
from IPython.core.display import HTML
from tqdm.auto import tqdm
HTML("<style>.jp-OutputArea-prompt:empty {padding: 0; border: 0;}</style>")
outer = range(5)
inner = range(5)
for var1 in tqdm(outer, desc="outer", position=0):
for var2 in tqdm(inner, desc="inner", position=1, leave=False):
time.sleep(0.5) |
I have submitted a PR in #12838. |
Re-opening the issue to keep track of the edge case found by Jason Grout: However, if there is only one output, we still end up with a minimum height of the output even with this PR. In stock JupyterLab, this means that closing a single displayed widget will still show a 20px blank space. Here's an example:
The problem appears to be the collapser minimum height if there is any output (and in this case, there is, according to jlab, and single empty output): jupyterlab/packages/cells/style/widget.css Lines 59 to 61 in f573c4a
Originally posted by @jasongrout in #12838 (comment) |
After much trial and error this is the only workaround that worked for me in JupyterLab: from IPython.core.display import HTML
# See https://github.com/bstriner/keras-tqdm/issues/21#issuecomment-443019223
display(HTML("""
<style>
.jp-OutputArea-child:has(.jp-OutputArea-prompt:empty) {
padding: 0 !important;
}
</style>
""")) |
I have not encountered this problem for quite a while. It appears that it has been fixed either downstream with tqdm or upstream somewhere. If someone encounters it again, please reopen or open a new issue. |
Can still reproduce it on vs code jupyter notebook :/ |
@Royal-lobster this is not a VSCode repository but JupyterLab repository. You may want to raise an issue with https://github.com/microsoft/vscode-jupyter. |
I see, looks like there is a open issue there. microsoft/vscode-jupyter#9397 would be waiting for it to get fixed |
Description
When using the progress meter
tqdm
and using the parameterleave
, meters should be redrawn in the location of a completed meter. There appears to be whitespace left behind when this redraw occurs. There has been a bug open intqdm
for a few years now. There is a comment by the author of that package that this bug is a problem in the upstream project, Jupyter / Jupyter Lab. I can verify that this bug still exists now. Screenshot is attached.Reproduce
Expected behavior
No extra accumulated white space.
Context
Command Line Output
Browser Output
The text was updated successfully, but these errors were encountered: