Skip to content

Conversation

@gowtham1412-p
Copy link

Summary

Ensures the WebAgg server URL is always displayed to users, even when the browser successfully opens automatically.

Problem

Currently, the URL is only shown when:

  • webagg.open_in_browser is False, OR
  • The browser fails to open

This means users never see the URL when the browser opens successfully, making it difficult to:

  • Share the URL with others
  • Open in a different browser
  • Reconnect if the tab is accidentally closed

Solution

Moved the print(f"To view figure, visit {url}") statement outside the conditional block, ensuring it always executes regardless of the browser open attempt.

Changes

  • File: lib/matplotlib/backends/backend_webagg.py
  • Method: FigureManagerWebAgg.pyplot_show()
  • Simplified conditional logic
  • URL now prints in all cases

Benefits

  • ✅ Users always know the exact URL to access their figures
  • ✅ Easier to reconnect if browser tab closes
  • ✅ Better user experience for remote/headless environments
  • ✅ Consistent behavior regardless of settings

Testing

Tested with:

  • webagg.open_in_browser = True → URL displays, browser opens
  • webagg.open_in_browser = False → URL displays, browser doesn't open
  • Simulated browser open failure → URL still displays

Fixes #15650

@rcomer
Copy link
Member

rcomer commented Nov 25, 2025

I am not familiar with webagg, but if a url successfully opens in a browser, can the user not see the url in the browser?

@rcomer rcomer added the status: needs clarification Issues that need more information to resolve. label Nov 25, 2025
Copy link
Contributor

@ianhi ianhi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in general in favor of more aggressive printing out of the url for all the reasons that you note. However, I don't think this is the right approach as leaves anyone using webagg as part of an application with a print statement that they cannot suppress, something that that they may not want.

Ideally there would be an escape hatch for that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

GUI: webagg status: needs clarification Issues that need more information to resolve.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

URL is not shown when webagg failed to open the browser.

3 participants