##// END OF EJS Templates
New feature: Added Gael ipython1 synchroneous shell for quick comparison and improvement....
ldufrechou -
Show More
@@ -44,7 +44,7 b' class _Helper(object):'
44
44
45 def __call__(self, *args, **kwds):
45 def __call__(self, *args, **kwds):
46 class DummyWriter(object):
46 class DummyWriter(object):
47 '''Dumy class to handle help output'''
47 '''Dumy class to handle help output'''
48 def __init__(self, pager):
48 def __init__(self, pager):
49 self._pager = pager
49 self._pager = pager
50
50
@@ -113,7 +113,6 b' class NonBlockingIPShell(object):'
113 '''
113 '''
114 #ipython0 initialisation
114 #ipython0 initialisation
115 self._IP = None
115 self._IP = None
116 self._term = None
117 self.initIpython0(argv, user_ns, user_global_ns,
116 self.initIpython0(argv, user_ns, user_global_ns,
118 cin, cout, cerr,
117 cin, cout, cerr,
119 ask_exit_handler)
118 ask_exit_handler)
@@ -139,21 +138,19 b' class NonBlockingIPShell(object):'
139 ask_exit_handler=None):
138 ask_exit_handler=None):
140 ''' Initialize an ipython0 instance '''
139 ''' Initialize an ipython0 instance '''
141
140
142 #first we redefine in/out/error functions of IPython
141 #first we redefine in/out/error functions of IPython
142 #BUG: we've got a limitation form ipython0 there
143 #only one instance can be instanciated else tehre will be
144 #cin/cout/cerr clash...
143 if cin:
145 if cin:
144 IPython.Shell.Term.cin = cin
146 IPython.genutils.Term.cin = cin
145 if cout:
147 if cout:
146 IPython.Shell.Term.cout = cout
148 IPython.genutils.Term.cout = cout
147 if cerr:
149 if cerr:
148 IPython.Shell.Term.cerr = cerr
150 IPython.genutils.Term.cerr = cerr
149
151
150 # This is to get rid of the blockage that accurs during
151 # IPython.Shell.InteractiveShell.user_setup()
152 IPython.iplib.raw_input = lambda x: None
153
154 self._term = IPython.genutils.IOTerm(cin=cin, cout=cout, cerr=cerr)
155
156 excepthook = sys.excepthook
152 excepthook = sys.excepthook
153
157 #Hack to save sys.displayhook, because ipython seems to overwrite it...
154 #Hack to save sys.displayhook, because ipython seems to overwrite it...
158 self.sys_displayhook_ori = sys.displayhook
155 self.sys_displayhook_ori = sys.displayhook
159
156
@@ -163,7 +160,8 b' class NonBlockingIPShell(object):'
163 embedded=True,
160 embedded=True,
164 shell_class=IPython.Shell.InteractiveShell)
161 shell_class=IPython.Shell.InteractiveShell)
165
162
166 #we restore sys.displayhook
163 #we save ipython0 displayhook and we restore sys.displayhook
164 self.displayhook = sys.displayhook
167 sys.displayhook = self.sys_displayhook_ori
165 sys.displayhook = self.sys_displayhook_ori
168
166
169 #we replace IPython default encoding by wx locale encoding
167 #we replace IPython default encoding by wx locale encoding
@@ -199,6 +197,7 b' class NonBlockingIPShell(object):'
199 """
197 """
200
198
201 self._line_to_execute = line
199 self._line_to_execute = line
200
202 if self._threading:
201 if self._threading:
203 #we launch the ipython line execution in a thread to make it interruptible
202 #we launch the ipython line execution in a thread to make it interruptible
204 #with include it in self namespace to be able to call ce.raise_exc(KeyboardInterrupt)
203 #with include it in self namespace to be able to call ce.raise_exc(KeyboardInterrupt)
@@ -214,6 +213,7 b' class NonBlockingIPShell(object):'
214
213
215 except KeyboardInterrupt:
214 except KeyboardInterrupt:
216 pass
215 pass
216
217 #----------------------- IPython management section ----------------------
217 #----------------------- IPython management section ----------------------
218 def getThreading(self):
218 def getThreading(self):
219 """
219 """
@@ -456,9 +456,12 b' class NonBlockingIPShell(object):'
456 '''
456 '''
457 Executes the current line provided by the shell object.
457 Executes the current line provided by the shell object.
458 '''
458 '''
459
459 orig_stdout = sys.stdout
460 orig_stdout = sys.stdout
460 sys.stdout = IPython.Shell.Term.cout
461 sys.stdout = IPython.Shell.Term.cout
461
462 #self.sys_displayhook_ori = sys.displayhook
463 #sys.displayhook = self.displayhook
464
462 try:
465 try:
463 line = self._IP.raw_input(None, self._iter_more)
466 line = self._IP.raw_input(None, self._iter_more)
464 if self._IP.autoindent:
467 if self._IP.autoindent:
@@ -486,8 +489,10 b' class NonBlockingIPShell(object):'
486 else:
489 else:
487 self._prompt = str(self._IP.outputcache.prompt1).strip()
490 self._prompt = str(self._IP.outputcache.prompt1).strip()
488 self._IP.indent_current_nsp = 0 #we set indentation to 0
491 self._IP.indent_current_nsp = 0 #we set indentation to 0
492
489 sys.stdout = orig_stdout
493 sys.stdout = orig_stdout
490
494 #sys.displayhook = self.sys_displayhook_ori
495
491 def _shell(self, ip, cmd):
496 def _shell(self, ip, cmd):
492 '''
497 '''
493 Replacement method to allow shell commands without them blocking.
498 Replacement method to allow shell commands without them blocking.
@@ -10,6 +10,9 b' from wx.lib.wordwrap import wordwrap'
10 from IPython.gui.wx.ipython_view import IPShellWidget
10 from IPython.gui.wx.ipython_view import IPShellWidget
11 from IPython.gui.wx.ipython_history import IPythonHistoryPanel
11 from IPython.gui.wx.ipython_history import IPythonHistoryPanel
12
12
13 #used to invoke ipython1 wx implementation
14 from IPython.frontend.wx.ipythonx import IPythonXController
15
13 #used to create options.conf file in user directory
16 #used to create options.conf file in user directory
14 from IPython.ipapi import get
17 from IPython.ipapi import get
15
18
@@ -40,6 +43,7 b' class MyFrame(wx.Frame):'
40 self.history_panel.setOptionTrackerHook(self.optionSave)
43 self.history_panel.setOptionTrackerHook(self.optionSave)
41
44
42 self.ipython_panel = IPShellWidget(self,background_color = "BLACK")
45 self.ipython_panel = IPShellWidget(self,background_color = "BLACK")
46 self.ipython_panel2 = IPythonXController(self)
43 #self.ipython_panel = IPShellWidget(self,background_color = "WHITE")
47 #self.ipython_panel = IPShellWidget(self,background_color = "WHITE")
44
48
45 self.ipython_panel.setHistoryTrackerHook(self.history_panel.write)
49 self.ipython_panel.setHistoryTrackerHook(self.history_panel.write)
@@ -47,6 +51,9 b' class MyFrame(wx.Frame):'
47 self.ipython_panel.setAskExitHandler(self.OnExitDlg)
51 self.ipython_panel.setAskExitHandler(self.OnExitDlg)
48 self.ipython_panel.setOptionTrackerHook(self.optionSave)
52 self.ipython_panel.setOptionTrackerHook(self.optionSave)
49
53
54 #Create a notebook to display different IPython shell implementations
55 self.nb = wx.aui.AuiNotebook(self)
56
50 self.optionLoad()
57 self.optionLoad()
51
58
52 self.statusbar = self.createStatus()
59 self.statusbar = self.createStatus()
@@ -55,7 +62,10 b' class MyFrame(wx.Frame):'
55 ########################################################################
62 ########################################################################
56 ### add the panes to the manager
63 ### add the panes to the manager
57 # main panels
64 # main panels
58 self._mgr.AddPane(self.ipython_panel , wx.CENTER, "IPython Shell")
65 self._mgr.AddPane(self.nb , wx.CENTER, "IPython Shells")
66 self.nb.AddPage(self.ipython_panel , "IPython0 Shell")
67 self.nb.AddPage(self.ipython_panel2, "IPython1 Synchroneous Shell")
68
59 self._mgr.AddPane(self.history_panel , wx.RIGHT, "IPython history")
69 self._mgr.AddPane(self.history_panel , wx.RIGHT, "IPython history")
60
70
61 # now we specify some panel characteristics
71 # now we specify some panel characteristics
@@ -146,13 +156,6 b' class MyFrame(wx.Frame):'
146 about_menu = wx.Menu()
156 about_menu = wx.Menu()
147 about_menu.Append(wx.ID_HIGHEST+3, "About")
157 about_menu.Append(wx.ID_HIGHEST+3, "About")
148
158
149 #view_menu.AppendSeparator()
150 #options_menu = wx.Menu()
151 #options_menu.AppendCheckItem(wx.ID_HIGHEST+7, "Allow Floating")
152 #options_menu.AppendCheckItem(wx.ID_HIGHEST+8, "Transparent Hint")
153 #options_menu.AppendCheckItem(wx.ID_HIGHEST+9, "Transparent Hint Fade-in")
154
155
156 mb.Append(file_menu, "File")
159 mb.Append(file_menu, "File")
157 mb.Append(view_menu, "View")
160 mb.Append(view_menu, "View")
158 mb.Append(about_menu, "About")
161 mb.Append(about_menu, "About")
General Comments 0
You need to be logged in to leave comments. Login now