diff --git a/IPython/gui/wx/ipshell_nonblocking.py b/IPython/gui/wx/ipshell_nonblocking.py index 4afa5cf..def47c5 100644 --- a/IPython/gui/wx/ipshell_nonblocking.py +++ b/IPython/gui/wx/ipshell_nonblocking.py @@ -176,7 +176,7 @@ class NonBlockingIPShell(object): self._IP.set_hook('shell_hook', self._shell) #we replace the ipython default input command caller by our method - IPython.iplib.raw_input_original = self._raw_input + IPython.iplib.raw_input_original = self._raw_input_original #we replace the ipython default exit command by our method self._IP.exit = ask_exit_handler #we replace the help command @@ -189,26 +189,9 @@ class NonBlockingIPShell(object): print '%this magic is currently disabled.' ip.expose_magic('cpaste', bypass_magic) - def reset_magic(self, arg): - """Resets the namespace by removing all names defined by the user. - - Input/Output history are left around in case you need them.""" - - ans = True ##todo find away to ask the user... - ##seems hard to do it cleanly... - if not ans: - print 'Nothing done.' - return - user_ns = self.shell.user_ns - for i in self.magic_who_ls(): - del(user_ns[i]) - - # Also flush the private list of module references kept for script - # execution protection - self.shell._user_main_modules[:] = [] - - ip.expose_magic('reset', reset_magic) - + import __builtin__ + __builtin__.raw_input = self._raw_input + sys.excepthook = excepthook #----------------------- Thread management section ---------------------- @@ -416,11 +399,11 @@ class NonBlockingIPShell(object): ''' pass - #def _ask_exit(self): - # ''' - # Can be redefined to generate post event to exit the Ipython shell - # ''' - # pass + def _ask_exit(self): + ''' + Can be redefined to generate post event to exit the Ipython shell + ''' + pass def _get_history_max_index(self): ''' @@ -462,7 +445,7 @@ class NonBlockingIPShell(object): ''' self._doc_text = text - def _raw_input(self, prompt=''): + def _raw_input_original(self, prompt=''): ''' Custom raw_input() replacement. Get's current line from console buffer. @@ -474,6 +457,11 @@ class NonBlockingIPShell(object): ''' return self._line_to_execute + def _raw_input(self, prompt=''): + """ A replacement from python's raw_input. + """ + raise NotImplementedError + def _execute(self): ''' Executes the current line provided by the shell object. diff --git a/IPython/gui/wx/ipython_view.py b/IPython/gui/wx/ipython_view.py index 2f09242..11b5ceb 100644 --- a/IPython/gui/wx/ipython_view.py +++ b/IPython/gui/wx/ipython_view.py @@ -70,6 +70,29 @@ class WxNonBlockingIPShell(NonBlockingIPShell): button_info={ 'text':text, 'func':self.parent.doExecuteLine(func)}) + def _raw_input(self, prompt=''): + """ A replacement from python's raw_input. + """ + self.answer = None + wx.CallAfter(self._yesNoBox, prompt) + while self.answer is None: + wx.Yield() + return self.answer + + def _yesNoBox(self, prompt): + """ yes/no box managed with wx.CallAfter jsut in case caler is executed in a thread""" + dlg = wx.TextEntryDialog( + self.parent, prompt, + 'Input requested', 'Python') + dlg.SetValue("") + + answer = '' + if dlg.ShowModal() == wx.ID_OK: + answer = dlg.GetValue() + + dlg.Destroy() + self.answer = answer + def _ask_exit(self): wx.CallAfter(self.ask_exit_callback, ()) @@ -432,7 +455,6 @@ class WxConsoleView(stc.StyledTextCtrl): @return: Return True if event as been catched. @rtype: boolean ''' - if not self.AutoCompActive(): if event.GetKeyCode() == wx.WXK_HOME: if event.Modifiers == wx.MOD_NONE: