From d770eb952c8e54a2e02536114cbdcdfae01ee9c1 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Mon, 7 Oct 2013 14:16:31 -0400 Subject: [PATCH 1/2] Consider ourselves interactive if sys.flags.interactive is set. --- lib/matplotlib/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 8530ecc0c94c..3a8a1bd1c192 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -1191,7 +1191,8 @@ def interactive(b): def is_interactive(): 'Return true if plot mode is interactive' - b = rcParams['interactive'] and hasattr(sys, 'ps1') + b = rcParams['interactive'] and ( + hasattr(sys, 'ps1') or sys.flags.interactive) return b def tk_window_focus(): From 02fc2611a874faa587b9e01ef6b0643c3e5dbfdc Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Wed, 23 Oct 2013 09:07:39 -0400 Subject: [PATCH 2/2] Add comment --- lib/matplotlib/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 3a8a1bd1c192..3f9e8bbcb297 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -1191,6 +1191,9 @@ def interactive(b): def is_interactive(): 'Return true if plot mode is interactive' + # ps1 exists if the python interpreter is running in an + # interactive console; sys.flags.interactive is true if a script + # is being run via "python -i". b = rcParams['interactive'] and ( hasattr(sys, 'ps1') or sys.flags.interactive) return b