Show More
@@ -38,6 +38,8 b' from IPython.config.loader import (' | |||
|
38 | 38 | PyFileConfigLoader |
|
39 | 39 | ) |
|
40 | 40 | |
|
41 | from IPython.lib import inputhook | |
|
42 | ||
|
41 | 43 | from IPython.utils.ipstruct import Struct |
|
42 | 44 | from IPython.utils.genutils import filefind, get_ipython_dir |
|
43 | 45 | |
@@ -52,12 +54,23 b' introspection, easier configuration, command completion, access to the system' | |||
|
52 | 54 | shell and more. |
|
53 | 55 | """ |
|
54 | 56 | |
|
55 |
def |
|
|
57 | def pylab_warning(): | |
|
56 | 58 | msg = """ |
|
57 | 59 | |
|
58 | The IPython threaded shells and their associated command line | |
|
59 | arguments (pylab/wthread/gthread/qthread/q4thread) have been | |
|
60 | deprecated. See the %gui magic for information on the new interface. | |
|
60 | IPython's -pylab mode has been disabled until matplotlib supports this version | |
|
61 | of IPython. This version of IPython has greatly improved GUI integration that | |
|
62 | matplotlib will soon be able to take advantage of. This will eventually | |
|
63 | result in greater stability and a richer API for matplotlib under IPython. | |
|
64 | However during this transition, you will either need to use an older version | |
|
65 | of IPython, or do the following to use matplotlib interactively:: | |
|
66 | ||
|
67 | import matplotlib | |
|
68 | matplotlib.interactive(True) | |
|
69 | matplotlib.use('wxagg') # adjust for your backend | |
|
70 | %gui -a wx # adjust for your GUI | |
|
71 | from matplotlib import pyplot as plt | |
|
72 | ||
|
73 | See the %gui magic for information on the new interface. | |
|
61 | 74 | """ |
|
62 | 75 | warnings.warn(msg, category=DeprecationWarning, stacklevel=1) |
|
63 | 76 | |
@@ -255,11 +268,23 b' cl_args = (' | |||
|
255 | 268 | action='store_true', dest='Global.force_interact', default=NoConfigDefault, |
|
256 | 269 | help="If running code from the command line, become interactive afterwards.") |
|
257 | 270 | ), |
|
258 | # These are only here to get the proper deprecation warnings | |
|
259 | (('-pylab','-wthread','-qthread','-q4thread','-gthread'), dict( | |
|
260 | action='store_true', dest='Global.threaded_shell', default=NoConfigDefault, | |
|
261 | help="These command line flags are deprecated, see the 'gui' magic.") | |
|
271 | (('-wthread',), dict( | |
|
272 | action='store_true', dest='Global.wthread', default=NoConfigDefault, | |
|
273 | help="Enable wxPython event loop integration.") | |
|
274 | ), | |
|
275 | (('-q4thread','-qthread'), dict( | |
|
276 | action='store_true', dest='Global.q4thread', default=NoConfigDefault, | |
|
277 | help="Enable Qt4 event loop integration. Qt3 is no longer supported.") | |
|
262 | 278 | ), |
|
279 | (('-gthread',), dict( | |
|
280 | action='store_true', dest='Global.gthread', default=NoConfigDefault, | |
|
281 | help="Enable GTK event loop integration.") | |
|
282 | ), | |
|
283 | # # These are only here to get the proper deprecation warnings | |
|
284 | (('-pylab',), dict( | |
|
285 | action='store_true', dest='Global.pylab', default=NoConfigDefault, | |
|
286 | help="Disabled. Pylab has been disabled until matplotlib supports this version of IPython.") | |
|
287 | ) | |
|
263 | 288 | ) |
|
264 | 289 | |
|
265 | 290 | |
@@ -284,13 +309,20 b' class IPythonApp(Application):' | |||
|
284 | 309 | # this and interact. It is also set by the -i cmd line flag, just |
|
285 | 310 | # like Python. |
|
286 | 311 | self.default_config.Global.force_interact = False |
|
312 | ||
|
287 | 313 | # By default always interact by starting the IPython mainloop. |
|
288 | 314 | self.default_config.Global.interact = True |
|
315 | ||
|
289 | 316 | # Let the parent class set the default, but each time log_level |
|
290 | 317 | # changes from config, we need to update self.log_level as that is |
|
291 | 318 | # what updates the actual log level in self.log. |
|
292 | 319 | self.default_config.Global.log_level = self.log_level |
|
293 | 320 | |
|
321 | # No GUI integration by default | |
|
322 | self.default_config.Global.wthread = False | |
|
323 | self.default_config.Global.q4thread = False | |
|
324 | self.default_config.Global.gthread = False | |
|
325 | ||
|
294 | 326 | def create_command_line_config(self): |
|
295 | 327 | """Create and return a command line config loader.""" |
|
296 | 328 | return IPythonAppCLConfigLoader( |
@@ -302,9 +334,9 b' class IPythonApp(Application):' | |||
|
302 | 334 | clc = self.command_line_config |
|
303 | 335 | |
|
304 | 336 | # Display the deprecation warnings about threaded shells |
|
305 |
if hasattr(clc.Global, ' |
|
|
306 |
|
|
|
307 |
del clc.Global[' |
|
|
337 | if hasattr(clc.Global, 'pylab'): | |
|
338 | pylab_warning() | |
|
339 | del clc.Global['pylab'] | |
|
308 | 340 | |
|
309 | 341 | def load_file_config(self): |
|
310 | 342 | if hasattr(self.command_line_config.Global, 'quick'): |
@@ -367,23 +399,44 b' class IPythonApp(Application):' | |||
|
367 | 399 | |
|
368 | 400 | def post_construct(self): |
|
369 | 401 | """Do actions after construct, but before starting the app.""" |
|
402 | config = self.master_config | |
|
403 | ||
|
370 | 404 | # shell.display_banner should always be False for the terminal |
|
371 | 405 | # based app, because we call shell.show_banner() by hand below |
|
372 | 406 | # so the banner shows *before* all extension loading stuff. |
|
373 | 407 | self.shell.display_banner = False |
|
374 | 408 | |
|
375 |
if |
|
|
376 |
|
|
|
409 | if config.Global.display_banner and \ | |
|
410 | config.Global.interact: | |
|
377 | 411 | self.shell.show_banner() |
|
378 | 412 | |
|
379 | 413 | # Make sure there is a space below the banner. |
|
380 | 414 | if self.log_level <= logging.INFO: print |
|
381 | 415 | |
|
416 | self._enable_gui() | |
|
382 | 417 | self._load_extensions() |
|
383 | 418 | self._run_exec_lines() |
|
384 | 419 | self._run_exec_files() |
|
385 | 420 | self._run_cmd_line_code() |
|
386 | 421 | |
|
422 | def _enable_gui(self): | |
|
423 | """Enable GUI event loop integration.""" | |
|
424 | config = self.master_config | |
|
425 | try: | |
|
426 | # Enable GUI integration | |
|
427 | if config.Global.wthread: | |
|
428 | self.log.info("Enabling wx GUI event loop integration") | |
|
429 | inputhook.enable_wx(app=True) | |
|
430 | elif config.Global.q4thread: | |
|
431 | self.log.info("Enabling Qt4 GUI event loop integration") | |
|
432 | inputhook.enable_qt4(app=True) | |
|
433 | elif config.Global.gthread: | |
|
434 | self.log.info("Enabling GTK GUI event loop integration") | |
|
435 | inputhook.enable_gtk(app=True) | |
|
436 | except: | |
|
437 | self.log.warn("Error in enabling GUI event loop integration:") | |
|
438 | self.shell.showtraceback() | |
|
439 | ||
|
387 | 440 | def _load_extensions(self): |
|
388 | 441 | """Load all IPython extensions in Global.extensions. |
|
389 | 442 |
General Comments 0
You need to be logged in to leave comments.
Login now