Esempio n. 1
0
def _init_ipython_session(is_wx, source=None, argv=[]):
    """
    Construct new IPython session.
    """
    import IPython
    if IPython.__version__ >= '0.11':
        from IPython.frontend.terminal import ipapp
        # Use an app to parse the command line, and init config.
        app = ipapp.TerminalIPythonApp()
        # Don't draw IPython banner during initialization.
        app.display_banner = False
        app.initialize(argv)
        ip = app.shell

        if is_wx:
            import wx
            from IPython.lib.inputhook import enable_wx
            wxapp = wx.GetApp()
            enable_wx(wxapp)

    else:
        if is_wx:
            from IPython.Shell import IPShellWX

            if source is None:
                source = preexec_source

            aux = {}
            exec source in aux
            ip = IPShellWX(argv, user_ns=aux)

        else:
            ip = IPython.Shell.make_IPython(argv)

    return ip
Esempio n. 2
0
def _init_ipython_session(is_wx, source=None, argv=[]):
    """
    Construct new IPython session.
    """
    import IPython
    if IPython.__version__ >= '0.11':
        from IPython.frontend.terminal import ipapp
        # Use an app to parse the command line, and init config.
        app = ipapp.TerminalIPythonApp()
        # Don't draw IPython banner during initialization.
        app.display_banner = False
        app.initialize(argv)
        ip = app.shell

        if is_wx:
            import wx
            from IPython.lib.inputhook import enable_wx
            wxapp = wx.GetApp()
            enable_wx(wxapp)

    else:
        if is_wx:
            from IPython.Shell import IPShellWX

            if source is None:
                source = preexec_source

            aux = {}
            exec source in aux
            ip = IPShellWX(argv, user_ns=aux)

        else:
            ip = IPython.Shell.make_IPython(argv)

    return ip
Esempio n. 3
0
def get_wx_app(redirect=False):
    global _wx_app
    if _wx_app is None:
        if _in_ipython:
            _wx_app = guisupport.get_app_wx()
            if IPython.__version__ >= "0.12":
                if kernelapp.IPKernelApp.initialized():
                    eventloops.enable_gui("wx")
            inputhook.enable_wx(_wx_app)
            guisupport.start_event_loop_wx(_wx_app)
        else:
            _wx_app = wx.App(redirect=redirect)
    return _wx_app
Esempio n. 4
0
def get_wx_app(redirect=False):
    global _wx_app
    if _wx_app is None:
        if _in_ipython:
            _wx_app = guisupport.get_app_wx()
            if IPython.__version__ >= "0.12":
                if kernelapp.IPKernelApp.initialized():
                    eventloops.enable_gui("wx")
            inputhook.enable_wx(_wx_app)
            guisupport.start_event_loop_wx(_wx_app)
        else:
            _wx_app = wx.App(redirect=redirect)
    return _wx_app
Esempio n. 5
0
 def _enable_gui(self):
     """Enable GUI event loop integration."""
     config = self.master_config
     try:
         # Enable GUI integration
         if config.Global.wthread:
             self.log.info("Enabling wx GUI event loop integration")
             inputhook.enable_wx(app=True)
         elif config.Global.q4thread:
             self.log.info("Enabling Qt4 GUI event loop integration")
             inputhook.enable_qt4(app=True)
         elif config.Global.gthread:
             self.log.info("Enabling GTK GUI event loop integration")
             inputhook.enable_gtk(app=True)
     except:
         self.log.warn("Error in enabling GUI event loop integration:")
         self.shell.showtraceback()
Esempio n. 6
0
def open(filename, redirect=False):
    """
    Opens a new mdf viewer with a picked context file.
    """
    # get/create a wx.App
    if _in_ipython:
        app = guisupport.get_app_wx()
    else:
        app = wx.App(redirect=redirect)

    frame = MDFViewerFrame(None, -1, "MDF Viewer", size=(800, 600))
    frame.CenterOnScreen()
    frame.Open(filename)
    frame.Show()

    if _in_ipython:
        inputhook.enable_wx(app)
    else:
        app.MainLoop()
Esempio n. 7
0
def open(filename, redirect=False):
    """
    Opens a new mdf viewer with a picked context file.
    """
    # get/create a wx.App
    if _in_ipython:
        app = guisupport.get_app_wx()
    else:
        app = wx.App(redirect=redirect)

    frame = MDFViewerFrame(None, -1, "MDF Viewer", size=(800, 600))
    frame.CenterOnScreen()
    frame.Open(filename)
    frame.Show()

    if _in_ipython:
        inputhook.enable_wx(app)
    else:
        app.MainLoop()
Esempio n. 8
0
        """Event handler for the button click."""
        print("Having fun yet?")


class MyApp(wx.App):
    def OnInit(self):
        frame = MyFrame(None, "Simple wxPython App")
        self.SetTopWindow(frame)

        print("Print statements go to this stdout window by default.")

        frame.Show(True)
        return True


if __name__ == '__main__':
    raise NotImplementedError(
        'Standalone WX GUI support is currently broken. '
        'See https://github.com/ipython/ipython/issues/645 for details')

    app = wx.GetApp()
    if app is None:
        app = MyApp(redirect=False, clearSigInt=False)

    try:
        from IPython.lib.inputhook import enable_wx
        enable_wx(app)
    except ImportError:
        app.MainLoop()

Esempio n. 9
0
        print("Having fun yet?")


class MyApp(wx.App):
    def OnInit(self):
        frame = MyFrame(None, "Simple wxPython App")
        self.SetTopWindow(frame)

        print("Print statements go to this stdout window by default.")

        frame.Show(True)
        return True


if __name__ == '__main__':

    app = wx.GetApp()
    if app is None:
        app = MyApp(redirect=False, clearSigInt=False)
    else:
        frame = MyFrame(None, "Simple wxPython App")
        app.SetTopWindow(frame)
        print("Print statements go to this stdout window by default.")
        frame.Show(True)

    try:
        from IPython.lib.inputhook import enable_wx
        enable_wx(app)
    except ImportError:
        app.MainLoop()