mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
|
||||
import sys
|
||||
from import_hook import import_hook_manager
|
||||
|
||||
backends = {'tk': 'TkAgg',
|
||||
'gtk': 'GTKAgg',
|
||||
@@ -57,6 +56,16 @@ def patch_use(interpreter):
|
||||
setattr(matplotlib, "use", patched_use)
|
||||
|
||||
|
||||
def patch_is_interactive():
|
||||
""" Patch matplotlib function 'use' """
|
||||
matplotlib = sys.modules['matplotlib']
|
||||
def patched_is_interactive():
|
||||
return matplotlib.rcParams['interactive']
|
||||
|
||||
setattr(matplotlib, "real_is_interactive", getattr(matplotlib, "is_interactive"))
|
||||
setattr(matplotlib, "is_interactive", patched_is_interactive)
|
||||
|
||||
|
||||
def activate_matplotlib(interpreter):
|
||||
"""Set interactive to True for interactive backends."""
|
||||
def activate_matplotlib_inner():
|
||||
@@ -73,13 +82,10 @@ def activate_matplotlib(interpreter):
|
||||
sys.stdout.write("Backend %s is non-interactive backend. Turning interactive mode off.\n" % backend)
|
||||
matplotlib.interactive(False)
|
||||
patch_use(interpreter)
|
||||
patch_is_interactive()
|
||||
return activate_matplotlib_inner
|
||||
|
||||
|
||||
def init_matplotlib(interpreter):
|
||||
import_hook_manager.add_module_name("matplotlib", activate_matplotlib(interpreter))
|
||||
|
||||
|
||||
def flag_calls(func):
|
||||
"""Wrap a function to detect and flag when it gets called.
|
||||
|
||||
@@ -116,17 +122,9 @@ def activate_pylab():
|
||||
pylab.draw_if_interactive = flag_calls(pylab.draw_if_interactive)
|
||||
|
||||
|
||||
def init_pylab():
|
||||
import_hook_manager.add_module_name("pylab", activate_pylab)
|
||||
|
||||
|
||||
def activate_pyplot():
|
||||
pyplot = sys.modules['matplotlib.pyplot']
|
||||
pyplot.show._needmain = False
|
||||
# We need to detect at runtime whether show() is called by the user.
|
||||
# For this, we wrap it into a decorator which adds a 'called' flag.
|
||||
pyplot.draw_if_interactive = flag_calls(pyplot.draw_if_interactive)
|
||||
|
||||
|
||||
def init_pyplot():
|
||||
import_hook_manager.add_module_name("pyplot", activate_pyplot)
|
||||
@@ -171,10 +171,11 @@ def process_exec_queue(interpreter):
|
||||
|
||||
set_return_control_callback(return_control)
|
||||
|
||||
from pydev_ipython.matplotlibtools import init_matplotlib, init_pylab, init_pyplot
|
||||
init_matplotlib(interpreter)
|
||||
init_pylab()
|
||||
init_pyplot()
|
||||
from pydev_import_hook import import_hook_manager
|
||||
from pydev_ipython.matplotlibtools import activate_matplotlib, activate_pylab, activate_pyplot
|
||||
import_hook_manager.add_module_name("matplotlib", activate_matplotlib(interpreter))
|
||||
import_hook_manager.add_module_name("pylab", activate_pylab)
|
||||
import_hook_manager.add_module_name("pyplot", activate_pyplot)
|
||||
|
||||
while 1:
|
||||
# Running the request may have changed the inputhook in use
|
||||
|
||||
Reference in New Issue
Block a user