refactoring in pydev console

This commit is contained in:
Elizaveta Shashkova
2014-10-29 20:02:52 +03:00
parent 08587225e9
commit afe9b5c056
3 changed files with 5 additions and 17 deletions
@@ -1,6 +1,5 @@
import sys
from import_hook import import_hook_manager
backends = {'tk': 'TkAgg',
'gtk': 'GTKAgg',
@@ -87,10 +86,6 @@ def activate_matplotlib(interpreter):
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.
@@ -127,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)
+5 -4
View File
@@ -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