##// END OF EJS Templates
Reenabled -wthread/-q4thread/-gthread and added warning for -pylab....
Brian Granger -
Show More
@@ -38,6 +38,8 b' from IPython.config.loader import ('
38 PyFileConfigLoader
38 PyFileConfigLoader
39 )
39 )
40
40
41 from IPython.lib import inputhook
42
41 from IPython.utils.ipstruct import Struct
43 from IPython.utils.ipstruct import Struct
42 from IPython.utils.genutils import filefind, get_ipython_dir
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 shell and more.
54 shell and more.
53 """
55 """
54
56
55 def threaded_shell_warning():
57 def pylab_warning():
56 msg = """
58 msg = """
57
59
58 The IPython threaded shells and their associated command line
60 IPython's -pylab mode has been disabled until matplotlib supports this version
59 arguments (pylab/wthread/gthread/qthread/q4thread) have been
61 of IPython. This version of IPython has greatly improved GUI integration that
60 deprecated. See the %gui magic for information on the new interface.
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 warnings.warn(msg, category=DeprecationWarning, stacklevel=1)
75 warnings.warn(msg, category=DeprecationWarning, stacklevel=1)
63
76
@@ -255,11 +268,23 b' cl_args = ('
255 action='store_true', dest='Global.force_interact', default=NoConfigDefault,
268 action='store_true', dest='Global.force_interact', default=NoConfigDefault,
256 help="If running code from the command line, become interactive afterwards.")
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
271 (('-wthread',), dict(
259 (('-pylab','-wthread','-qthread','-q4thread','-gthread'), dict(
272 action='store_true', dest='Global.wthread', default=NoConfigDefault,
260 action='store_true', dest='Global.threaded_shell', default=NoConfigDefault,
273 help="Enable wxPython event loop integration.")
261 help="These command line flags are deprecated, see the 'gui' magic.")
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 # this and interact. It is also set by the -i cmd line flag, just
309 # this and interact. It is also set by the -i cmd line flag, just
285 # like Python.
310 # like Python.
286 self.default_config.Global.force_interact = False
311 self.default_config.Global.force_interact = False
312
287 # By default always interact by starting the IPython mainloop.
313 # By default always interact by starting the IPython mainloop.
288 self.default_config.Global.interact = True
314 self.default_config.Global.interact = True
315
289 # Let the parent class set the default, but each time log_level
316 # Let the parent class set the default, but each time log_level
290 # changes from config, we need to update self.log_level as that is
317 # changes from config, we need to update self.log_level as that is
291 # what updates the actual log level in self.log.
318 # what updates the actual log level in self.log.
292 self.default_config.Global.log_level = self.log_level
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 def create_command_line_config(self):
326 def create_command_line_config(self):
295 """Create and return a command line config loader."""
327 """Create and return a command line config loader."""
296 return IPythonAppCLConfigLoader(
328 return IPythonAppCLConfigLoader(
@@ -302,9 +334,9 b' class IPythonApp(Application):'
302 clc = self.command_line_config
334 clc = self.command_line_config
303
335
304 # Display the deprecation warnings about threaded shells
336 # Display the deprecation warnings about threaded shells
305 if hasattr(clc.Global, 'threaded_shell'):
337 if hasattr(clc.Global, 'pylab'):
306 threaded_shell_warning()
338 pylab_warning()
307 del clc.Global['threaded_shell']
339 del clc.Global['pylab']
308
340
309 def load_file_config(self):
341 def load_file_config(self):
310 if hasattr(self.command_line_config.Global, 'quick'):
342 if hasattr(self.command_line_config.Global, 'quick'):
@@ -367,23 +399,44 b' class IPythonApp(Application):'
367
399
368 def post_construct(self):
400 def post_construct(self):
369 """Do actions after construct, but before starting the app."""
401 """Do actions after construct, but before starting the app."""
402 config = self.master_config
403
370 # shell.display_banner should always be False for the terminal
404 # shell.display_banner should always be False for the terminal
371 # based app, because we call shell.show_banner() by hand below
405 # based app, because we call shell.show_banner() by hand below
372 # so the banner shows *before* all extension loading stuff.
406 # so the banner shows *before* all extension loading stuff.
373 self.shell.display_banner = False
407 self.shell.display_banner = False
374
408
375 if self.master_config.Global.display_banner and \
409 if config.Global.display_banner and \
376 self.master_config.Global.interact:
410 config.Global.interact:
377 self.shell.show_banner()
411 self.shell.show_banner()
378
412
379 # Make sure there is a space below the banner.
413 # Make sure there is a space below the banner.
380 if self.log_level <= logging.INFO: print
414 if self.log_level <= logging.INFO: print
381
415
416 self._enable_gui()
382 self._load_extensions()
417 self._load_extensions()
383 self._run_exec_lines()
418 self._run_exec_lines()
384 self._run_exec_files()
419 self._run_exec_files()
385 self._run_cmd_line_code()
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 def _load_extensions(self):
440 def _load_extensions(self):
388 """Load all IPython extensions in Global.extensions.
441 """Load all IPython extensions in Global.extensions.
389
442
General Comments 0
You need to be logged in to leave comments. Login now