##// END OF EJS Templates
add `--matplotlib` flag to terminal IPython...
MinRK -
Show More
@@ -103,6 +103,11 b" shell_flags['pylab'] = ("
103 103 """Pre-load matplotlib and numpy for interactive use with
104 104 the default matplotlib backend."""
105 105 )
106 shell_flags['matplotlib'] = (
107 {'InteractiveShellApp' : {'matplotlib' : 'auto'}},
108 """Configure matplotlib for interactive use with
109 the default matplotlib backend."""
110 )
106 111
107 112 # it's possible we don't want short aliases for *all* of these:
108 113 shell_aliases = dict(
@@ -115,6 +120,7 b' shell_aliases = dict('
115 120 ext='InteractiveShellApp.extra_extension',
116 121 gui='InteractiveShellApp.gui',
117 122 pylab='InteractiveShellApp.pylab',
123 matplotlib='InteractiveShellApp.matplotlib',
118 124 )
119 125 shell_aliases['cache-size'] = 'InteractiveShell.cache_size'
120 126
@@ -169,6 +175,11 b' class InteractiveShellApp(Configurable):'
169 175 gui = CaselessStrEnum(('qt', 'wx', 'gtk', 'glut', 'pyglet', 'osx'), config=True,
170 176 help="Enable GUI event loop integration ('qt', 'wx', 'gtk', 'glut', 'pyglet', 'osx')."
171 177 )
178 matplotlib = CaselessStrEnum(['tk', 'qt', 'wx', 'gtk', 'osx', 'inline', 'auto'],
179 config=True,
180 help="""Configure matplotlib for interactive use with
181 the default matplotlib backend."""
182 )
172 183 pylab = CaselessStrEnum(['tk', 'qt', 'wx', 'gtk', 'osx', 'inline', 'auto'],
173 184 config=True,
174 185 help="""Pre-load matplotlib and numpy for interactive use,
@@ -194,27 +205,42 b' class InteractiveShellApp(Configurable):'
194 205
195 206 def init_gui_pylab(self):
196 207 """Enable GUI event loop integration, taking pylab into account."""
197 if self.gui or self.pylab:
198 shell = self.shell
199 try:
200 if self.pylab:
201 gui, backend = pylabtools.find_gui_and_backend(self.pylab)
202 self.log.info("Enabling GUI event loop integration, "
203 "toolkit=%s, pylab=%s" % (gui, self.pylab))
204 if self.pylab == "auto":
205 print ("using matplotlib backend: %s" % backend)
206 shell.enable_pylab(self.pylab, import_all=self.pylab_import_all)
207 else:
208 self.log.info("Enabling GUI event loop integration, "
209 "toolkit=%s" % self.gui)
210 shell.enable_gui(self.gui)
211 except ImportError:
212 self.log.warn("pylab mode doesn't work as matplotlib could not be found." + \
213 "\nIs it installed on the system?")
214 self.shell.showtraceback()
215 except Exception:
216 self.log.warn("GUI event loop or pylab initialization failed")
217 self.shell.showtraceback()
208 enable = False
209 shell = self.shell
210 if self.pylab:
211 enable = shell.enable_pylab
212 key = self.pylab
213 elif self.matplotlib:
214 enable = shell.enable_matplotlib
215 key = self.matplotlib
216 elif self.gui:
217 enable = shell.enable_gui
218 key = self.gui
219
220 if not enable:
221 return
222
223 try:
224 r = enable(key)
225 except ImportError:
226 self.log.warn("Eventloop or matplotlib integration failed. Is matplotlib installed?")
227 self.shell.showtraceback()
228 return
229 except Exception:
230 self.log.warn("GUI event loop or pylab initialization failed")
231 self.shell.showtraceback()
232 return
233
234 if isinstance(r, tuple):
235 gui, backend = r[:2]
236 self.log.info("Enabling GUI event loop integration, "
237 "eventloop=%s, matplotlib=%s", gui, backend)
238 if key == "auto":
239 print ("using matplotlib backend: %s" % backend)
240 else:
241 gui = r
242 self.log.info("Enabling GUI event loop integration, "
243 "eventloop=%s", gui)
218 244
219 245 def init_extensions(self):
220 246 """Load all IPython extensions in IPythonApp.extensions.
General Comments 0
You need to be logged in to leave comments. Login now