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 does not capture print under IPython's %%capture magic #3892

Open
asaboor-gh opened this issue Mar 9, 2024 · 0 comments
Open

Comments

@asaboor-gh
Copy link

It might be a silly use case, but I noticed that if we are using Output widget under IPython's %%capture magic or capture_output contextmanger, it cannot capture print which goes on top level IPython capture only.

from IPython.utils.capture import capture_output
from ipywidgets import Output

out = Output()

with capture_output() as cap: # could be %%capture cap
    print("1. In main capture")

    with out:
        print("2. Still in main capture")
        display("3. In Output widget")

    print('4. before displaying out')
    display(out) # only display will be shown here but at end
    print('5. after displaying out')

cap.show()

image

It seems like Output is not able to acquire some kind of system display hooks. This also results in unordered output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant