diff --git a/larray_editor/api.py b/larray_editor/api.py index 08fd80a..eac1809 100644 --- a/larray_editor/api.py +++ b/larray_editor/api.py @@ -57,12 +57,16 @@ def _show_dialog(app_name, create_dialog_func, *args, **kwargs): # (see issue #253) or after showing matplotlib figures (see issue #261). # We have not found any way to explicitly check whether the main event loop - # is already running, so we now assume that if the parent window is not + # is already running (*), so we now assume that if the parent window is not # a descendant of our own MappingEditor, no event loop is running, as it is # unlikely another Qt application calls the *api functions* instead of # embedding the widget. Note that jupyter qtconsole works, because the # Python kernel process is not the same as the process running the # interface, so QApplication.instance() returns None in the kernel process. + + # (*) QEventLoop has an isRunning() method, but QCoreApplication *acts* + # as an event loop but does not inherit from QEventLoop, and it lacks + # the method. if parent is None: # We do not use install_except_hook/restore_except_hook so that we can restore the hook actually used when # this function is called instead of the one which was used when the module was loaded. diff --git a/larray_editor/tests/test_api_larray.py b/larray_editor/tests/test_api_larray.py index 7f9a323..17e8ad1 100644 --- a/larray_editor/tests/test_api_larray.py +++ b/larray_editor/tests/test_api_larray.py @@ -100,6 +100,15 @@ def make_demo(width=20, ball_radius=5, path_radius=5, steps=30): return la.maximum(ball_radius - la.sqrt((x - ball_center_x) ** 2 + (y - ball_center_y) ** 2), 0).transpose(x, y) +def test_matplotlib_show_interaction(): + import matplotlib.pyplot as plt + + arr = la.ndtest((3, 4)) + arr.plot() + plt.show() + edit() + + demo = make_demo(9, 2.5, 1.5) sphere = make_sphere(9, 4) extreme_array = la.Array([-la.inf, -1, 0, la.nan, 1, la.inf]) @@ -208,3 +217,5 @@ def test_run_editor_on_exception(local_arr): # run_editor_on_exception(usercode_traceback=False, usercode_frame=False) # test_run_editor_on_exception(arr2) + +test_matplotlib_show_interaction()