Skip to content

Commit 6e735d5

Browse files
committed
Display URL if not set to open webbrowser
1 parent 0c99763 commit 6e735d5

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/matplotlib/backends/backend_webagg.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,15 @@ def draw_if_interactive():
4444
class Show(backend_bases.ShowBase):
4545
def mainloop(self):
4646
WebAggApplication.initialize()
47-
if rcParams['webagg.open_in_browser']:
48-
import webbrowser
49-
print("Opening in webbrowser")
50-
for manager in Gcf.get_all_fig_managers():
51-
webbrowser.open("http://127.0.0.1:{0}/{1}/".format(
52-
WebAggApplication.port, manager.num))
47+
for manager in Gcf.get_all_fig_managers():
48+
url = "http://127.0.0.1:{0}/{1}/".format(
49+
WebAggApplication.port, manager.num)
50+
if rcParams['webagg.open_in_browser']:
51+
import webbrowser
52+
webbrowser.open(url)
53+
else:
54+
print("To view figure, visit {0}".format(url))
55+
5356
WebAggApplication.start()
5457

5558
show = Show()

0 commit comments

Comments
 (0)