mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
refactoring in pydev console
This commit is contained in:
@@ -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)
|
||||
@@ -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