Ticket #12824: IPythonX.patch

File IPythonX.patch, 2.4 KB (added by Sebastian Noack, 14 years ago)
  • django/django/core/management/commands/shell.py

    diff --git a/django/django/core/management/commands/shell.py b/django/django/core/management/commands/shell.py
    index 9616902..223b9ef 100644
    a b class Command(NoArgsCommand):  
    66    option_list = NoArgsCommand.option_list + (
    77        make_option('--plain', action='store_true', dest='plain',
    88            help='Tells Django to use plain Python, not IPython.'),
     9        make_option('--gui', action='store_true', dest='gui',
     10            help='Tells Django to use IPythonX, not IPython.'),
    911    )
    1012    help = "Runs a Python interactive interpreter. Tries to use IPython, if it's available."
    1113
    class Command(NoArgsCommand):  
    1820        loaded_models = get_models()
    1921
    2022        use_plain = options.get('plain', False)
     23        use_gui = options.get('gui', False)
    2124
    2225        try:
    2326            if use_plain:
    2427                # Don't bother loading IPython, because the user wants plain Python.
    2528                raise ImportError
     29
     30            if use_gui:
     31                try:
     32                    from IPython.frontend.wx.ipythonx import IPythonX, wx
     33
     34                    app = wx.PySimpleApp()
     35
     36                    frame = IPythonX(None, wx.ID_ANY, 'IPythonX')
     37                    frame.shell.SetFocus()
     38                    frame.shell.app = app
     39                    frame.SetSize((680, 460))
     40
     41                    app.MainLoop()
     42
     43                    return
     44                except ImportError:
     45                    pass
     46
    2647            import IPython
    2748            # Explicitly pass an empty list as arguments, because otherwise IPython
    2849            # would use sys.argv from this script.
    class Command(NoArgsCommand):  
    3556            # See ticket 5082.
    3657            imported_objects = {}
    3758            try: # Try activating rlcompleter, because it's handy.
    38                 import readline
     59                import readline, rlcompleter
    3960            except ImportError:
    4061                pass
    4162            else:
    4263                # We don't have to wrap the following import in a 'try', because
    4364                # we already know 'readline' was imported successfully.
    44                 import rlcompleter
    4565                readline.set_completer(rlcompleter.Completer(imported_objects).complete)
    4666                readline.parse_and_bind("tab:complete")
    4767
Back to Top