Skip to content

Commit d566ba6

Browse files
authored
Let Figure.show(method='external') work well in Python scripts (#1062)
1 parent b462cfc commit d566ba6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pygmt/helpers/utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import shutil
66
import subprocess
77
import sys
8+
import time
89
import webbrowser
910
from collections.abc import Iterable
1011
from contextlib import contextmanager
@@ -233,6 +234,9 @@ def launch_external_viewer(fname):
233234
os.startfile(fname) # pylint: disable=no-member
234235
else:
235236
webbrowser.open_new_tab(f"file://{fname}")
237+
# suspend the execution for 0.5 s to avoid the images being deleted
238+
# when a Python script exits
239+
time.sleep(0.5)
236240

237241

238242
def args_in_kwargs(args, kwargs):

0 commit comments

Comments
 (0)