From 0ff500655a512229165ca689a1996042cc655bee 2008-08-12 20:45:28 From: gvaroquaux Date: 2008-08-12 20:45:28 Subject: [PATCH] Tweak the debug mode. Add sensible cursors in raw_input. --- diff --git a/IPython/frontend/linefrontendbase.py b/IPython/frontend/linefrontendbase.py index fb450e8..1a5c360 100644 --- a/IPython/frontend/linefrontendbase.py +++ b/IPython/frontend/linefrontendbase.py @@ -66,7 +66,7 @@ class LineFrontEndBase(FrontEndBase): # FrontEndBase interface #-------------------------------------------------------------------------- - def __init__(self, shell=None, history=None): + def __init__(self, shell=None, history=None, *args, **kwargs): if shell is None: shell = Interpreter() FrontEndBase.__init__(self, shell=shell, history=history) diff --git a/IPython/frontend/wx/ipythonx.py b/IPython/frontend/wx/ipythonx.py index ff83ad3..d9b0762 100755 --- a/IPython/frontend/wx/ipythonx.py +++ b/IPython/frontend/wx/ipythonx.py @@ -66,10 +66,10 @@ class IPythonX(wx.Frame): """ Main frame of the IPythonX app. """ - def __init__(self, parent, id, title): + def __init__(self, parent, id, title, debug=False): wx.Frame.__init__(self, parent, id, title, size=(300,250)) self._sizer = wx.BoxSizer(wx.VERTICAL) - self.shell = IPythonXController(self) + self.shell = IPythonXController(self, debug=debug) self._sizer.Add(self.shell, 1, wx.EXPAND) self.SetSizer(self._sizer) self.SetAutoLayout(1) @@ -93,8 +93,7 @@ Simple graphical frontend to IPython, using WxWidgets.""" sys.argv = sys.argv[:1] app = wx.PySimpleApp() - frame = IPythonX(None, wx.ID_ANY, 'IPythonX') - frame.shell.debug = options.debug + frame = IPythonX(None, wx.ID_ANY, 'IPythonX', debug=options.debug) frame.shell.SetFocus() frame.shell.app = app frame.SetSize((680, 460)) diff --git a/IPython/frontend/wx/wx_frontend.py b/IPython/frontend/wx/wx_frontend.py index 18a14df..b0a1b71 100644 --- a/IPython/frontend/wx/wx_frontend.py +++ b/IPython/frontend/wx/wx_frontend.py @@ -140,7 +140,7 @@ class WxController(ConsoleWidget, PrefilterFrontEnd): """ Create Shell instance. """ ConsoleWidget.__init__(self, parent, id, pos, size, style) - PrefilterFrontEnd.__init__(self) + PrefilterFrontEnd.__init__(self, **kwds) # Marker for complete buffer. self.MarkerDefine(_COMPLETE_BUFFER_MARKER, stc.STC_MARK_BACKGROUND, @@ -157,6 +157,10 @@ class WxController(ConsoleWidget, PrefilterFrontEnd): self._buffer_flush_timer = wx.Timer(self, BUFFER_FLUSH_TIMER_ID) wx.EVT_TIMER(self, BUFFER_FLUSH_TIMER_ID, self._buffer_flush) + if 'debug' in kwds: + self.debug = kwds['debug'] + kwds.pop('debug') + # Inject self in namespace, for debug if self.debug: self.shell.user_ns['self'] = self @@ -167,6 +171,8 @@ class WxController(ConsoleWidget, PrefilterFrontEnd): """ self.new_prompt(prompt) self._input_state = 'raw_input' + del self._cursor + self.SetCursor(wx.StockCursor(wx.CURSOR_CROSS)) self.waiting = True self.__old_on_enter = self._on_enter def my_on_enter(): @@ -178,6 +184,7 @@ class WxController(ConsoleWidget, PrefilterFrontEnd): sleep(0.1) self._on_enter = self.__old_on_enter self._input_state = 'buffering' + self._cursor = wx.BusyCursor() return self.input_buffer.rstrip('\n') @@ -214,9 +221,9 @@ class WxController(ConsoleWidget, PrefilterFrontEnd): symbol = __builtin__.__dict__[base_symbol_string] else: return False - for name in symbol_string.split('.')[1:] + ['__doc__']: - symbol = getattr(symbol, name) try: + for name in symbol_string.split('.')[1:] + ['__doc__']: + symbol = getattr(symbol, name) self.AutoCompCancel() wx.Yield() self.CallTipShow(self.GetCurrentPos(), symbol) @@ -299,6 +306,7 @@ class WxController(ConsoleWidget, PrefilterFrontEnd): # Clear the wait cursor if hasattr(self, '_cursor'): del self._cursor + self.SetCursor(wx.StockCursor(wx.CURSOR_CHAR)) def show_traceback(self):