diff --git a/IPython/gui/wx/ipshell_nonblocking.py b/IPython/gui/wx/ipshell_nonblocking.py index 9657c7d..e09151e 100644 --- a/IPython/gui/wx/ipshell_nonblocking.py +++ b/IPython/gui/wx/ipshell_nonblocking.py @@ -44,7 +44,7 @@ class _Helper(object): def __call__(self, *args, **kwds): class DummyWriter(object): - '''Dumy class to handle help output''' + '''Dumy class to handle help output''' def __init__(self, pager): self._pager = pager @@ -113,7 +113,6 @@ class NonBlockingIPShell(object): ''' #ipython0 initialisation self._IP = None - self._term = None self.initIpython0(argv, user_ns, user_global_ns, cin, cout, cerr, ask_exit_handler) @@ -139,21 +138,19 @@ class NonBlockingIPShell(object): ask_exit_handler=None): ''' Initialize an ipython0 instance ''' - #first we redefine in/out/error functions of IPython + #first we redefine in/out/error functions of IPython + #BUG: we've got a limitation form ipython0 there + #only one instance can be instanciated else tehre will be + #cin/cout/cerr clash... if cin: - IPython.Shell.Term.cin = cin + IPython.genutils.Term.cin = cin if cout: - IPython.Shell.Term.cout = cout + IPython.genutils.Term.cout = cout if cerr: - IPython.Shell.Term.cerr = cerr + IPython.genutils.Term.cerr = cerr - # This is to get rid of the blockage that accurs during - # IPython.Shell.InteractiveShell.user_setup() - IPython.iplib.raw_input = lambda x: None - - self._term = IPython.genutils.IOTerm(cin=cin, cout=cout, cerr=cerr) - excepthook = sys.excepthook + #Hack to save sys.displayhook, because ipython seems to overwrite it... self.sys_displayhook_ori = sys.displayhook @@ -163,7 +160,8 @@ class NonBlockingIPShell(object): embedded=True, shell_class=IPython.Shell.InteractiveShell) - #we restore sys.displayhook + #we save ipython0 displayhook and we restore sys.displayhook + self.displayhook = sys.displayhook sys.displayhook = self.sys_displayhook_ori #we replace IPython default encoding by wx locale encoding @@ -199,6 +197,7 @@ class NonBlockingIPShell(object): """ self._line_to_execute = line + if self._threading: #we launch the ipython line execution in a thread to make it interruptible #with include it in self namespace to be able to call ce.raise_exc(KeyboardInterrupt) @@ -214,6 +213,7 @@ class NonBlockingIPShell(object): except KeyboardInterrupt: pass + #----------------------- IPython management section ---------------------- def getThreading(self): """ @@ -456,9 +456,12 @@ class NonBlockingIPShell(object): ''' Executes the current line provided by the shell object. ''' + orig_stdout = sys.stdout sys.stdout = IPython.Shell.Term.cout - + #self.sys_displayhook_ori = sys.displayhook + #sys.displayhook = self.displayhook + try: line = self._IP.raw_input(None, self._iter_more) if self._IP.autoindent: @@ -486,8 +489,10 @@ class NonBlockingIPShell(object): else: self._prompt = str(self._IP.outputcache.prompt1).strip() self._IP.indent_current_nsp = 0 #we set indentation to 0 + sys.stdout = orig_stdout - + #sys.displayhook = self.sys_displayhook_ori + def _shell(self, ip, cmd): ''' Replacement method to allow shell commands without them blocking. diff --git a/IPython/gui/wx/wxIPython.py b/IPython/gui/wx/wxIPython.py index 759ab73..aac8915 100755 --- a/IPython/gui/wx/wxIPython.py +++ b/IPython/gui/wx/wxIPython.py @@ -10,6 +10,9 @@ from wx.lib.wordwrap import wordwrap from IPython.gui.wx.ipython_view import IPShellWidget from IPython.gui.wx.ipython_history import IPythonHistoryPanel +#used to invoke ipython1 wx implementation +from IPython.frontend.wx.ipythonx import IPythonXController + #used to create options.conf file in user directory from IPython.ipapi import get @@ -40,6 +43,7 @@ class MyFrame(wx.Frame): self.history_panel.setOptionTrackerHook(self.optionSave) self.ipython_panel = IPShellWidget(self,background_color = "BLACK") + self.ipython_panel2 = IPythonXController(self) #self.ipython_panel = IPShellWidget(self,background_color = "WHITE") self.ipython_panel.setHistoryTrackerHook(self.history_panel.write) @@ -47,6 +51,9 @@ class MyFrame(wx.Frame): self.ipython_panel.setAskExitHandler(self.OnExitDlg) self.ipython_panel.setOptionTrackerHook(self.optionSave) + #Create a notebook to display different IPython shell implementations + self.nb = wx.aui.AuiNotebook(self) + self.optionLoad() self.statusbar = self.createStatus() @@ -55,7 +62,10 @@ class MyFrame(wx.Frame): ######################################################################## ### add the panes to the manager # main panels - self._mgr.AddPane(self.ipython_panel , wx.CENTER, "IPython Shell") + self._mgr.AddPane(self.nb , wx.CENTER, "IPython Shells") + self.nb.AddPage(self.ipython_panel , "IPython0 Shell") + self.nb.AddPage(self.ipython_panel2, "IPython1 Synchroneous Shell") + self._mgr.AddPane(self.history_panel , wx.RIGHT, "IPython history") # now we specify some panel characteristics @@ -146,13 +156,6 @@ class MyFrame(wx.Frame): about_menu = wx.Menu() about_menu.Append(wx.ID_HIGHEST+3, "About") - #view_menu.AppendSeparator() - #options_menu = wx.Menu() - #options_menu.AppendCheckItem(wx.ID_HIGHEST+7, "Allow Floating") - #options_menu.AppendCheckItem(wx.ID_HIGHEST+8, "Transparent Hint") - #options_menu.AppendCheckItem(wx.ID_HIGHEST+9, "Transparent Hint Fade-in") - - mb.Append(file_menu, "File") mb.Append(view_menu, "View") mb.Append(about_menu, "About")