Show More
@@ -176,7 +176,7 b' class NonBlockingIPShell(object):' | |||
|
176 | 176 | self._IP.set_hook('shell_hook', self._shell) |
|
177 | 177 | |
|
178 | 178 | #we replace the ipython default input command caller by our method |
|
179 | IPython.iplib.raw_input_original = self._raw_input | |
|
179 | IPython.iplib.raw_input_original = self._raw_input_original | |
|
180 | 180 | #we replace the ipython default exit command by our method |
|
181 | 181 | self._IP.exit = ask_exit_handler |
|
182 | 182 | #we replace the help command |
@@ -189,25 +189,8 b' class NonBlockingIPShell(object):' | |||
|
189 | 189 | print '%this magic is currently disabled.' |
|
190 | 190 | ip.expose_magic('cpaste', bypass_magic) |
|
191 | 191 | |
|
192 | def reset_magic(self, arg): | |
|
193 | """Resets the namespace by removing all names defined by the user. | |
|
194 | ||
|
195 | Input/Output history are left around in case you need them.""" | |
|
196 | ||
|
197 | ans = True ##todo find away to ask the user... | |
|
198 | ##seems hard to do it cleanly... | |
|
199 | if not ans: | |
|
200 | print 'Nothing done.' | |
|
201 | return | |
|
202 | user_ns = self.shell.user_ns | |
|
203 | for i in self.magic_who_ls(): | |
|
204 | del(user_ns[i]) | |
|
205 | ||
|
206 | # Also flush the private list of module references kept for script | |
|
207 | # execution protection | |
|
208 | self.shell._user_main_modules[:] = [] | |
|
209 | ||
|
210 | ip.expose_magic('reset', reset_magic) | |
|
192 | import __builtin__ | |
|
193 | __builtin__.raw_input = self._raw_input | |
|
211 | 194 | |
|
212 | 195 | sys.excepthook = excepthook |
|
213 | 196 | |
@@ -416,11 +399,11 b' class NonBlockingIPShell(object):' | |||
|
416 | 399 | ''' |
|
417 | 400 | pass |
|
418 | 401 | |
|
419 |
|
|
|
420 |
|
|
|
421 |
|
|
|
422 |
|
|
|
423 |
|
|
|
402 | def _ask_exit(self): | |
|
403 | ''' | |
|
404 | Can be redefined to generate post event to exit the Ipython shell | |
|
405 | ''' | |
|
406 | pass | |
|
424 | 407 | |
|
425 | 408 | def _get_history_max_index(self): |
|
426 | 409 | ''' |
@@ -462,7 +445,7 b' class NonBlockingIPShell(object):' | |||
|
462 | 445 | ''' |
|
463 | 446 | self._doc_text = text |
|
464 | 447 | |
|
465 | def _raw_input(self, prompt=''): | |
|
448 | def _raw_input_original(self, prompt=''): | |
|
466 | 449 | ''' |
|
467 | 450 | Custom raw_input() replacement. Get's current line from console buffer. |
|
468 | 451 | |
@@ -474,6 +457,11 b' class NonBlockingIPShell(object):' | |||
|
474 | 457 | ''' |
|
475 | 458 | return self._line_to_execute |
|
476 | 459 | |
|
460 | def _raw_input(self, prompt=''): | |
|
461 | """ A replacement from python's raw_input. | |
|
462 | """ | |
|
463 | raise NotImplementedError | |
|
464 | ||
|
477 | 465 | def _execute(self): |
|
478 | 466 | ''' |
|
479 | 467 | Executes the current line provided by the shell object. |
@@ -70,6 +70,29 b' class WxNonBlockingIPShell(NonBlockingIPShell):' | |||
|
70 | 70 | button_info={ 'text':text, |
|
71 | 71 | 'func':self.parent.doExecuteLine(func)}) |
|
72 | 72 | |
|
73 | def _raw_input(self, prompt=''): | |
|
74 | """ A replacement from python's raw_input. | |
|
75 | """ | |
|
76 | self.answer = None | |
|
77 | wx.CallAfter(self._yesNoBox, prompt) | |
|
78 | while self.answer is None: | |
|
79 | wx.Yield() | |
|
80 | return self.answer | |
|
81 | ||
|
82 | def _yesNoBox(self, prompt): | |
|
83 | """ yes/no box managed with wx.CallAfter jsut in case caler is executed in a thread""" | |
|
84 | dlg = wx.TextEntryDialog( | |
|
85 | self.parent, prompt, | |
|
86 | 'Input requested', 'Python') | |
|
87 | dlg.SetValue("") | |
|
88 | ||
|
89 | answer = '' | |
|
90 | if dlg.ShowModal() == wx.ID_OK: | |
|
91 | answer = dlg.GetValue() | |
|
92 | ||
|
93 | dlg.Destroy() | |
|
94 | self.answer = answer | |
|
95 | ||
|
73 | 96 | def _ask_exit(self): |
|
74 | 97 | wx.CallAfter(self.ask_exit_callback, ()) |
|
75 | 98 | |
@@ -432,7 +455,6 b' class WxConsoleView(stc.StyledTextCtrl):' | |||
|
432 | 455 | @return: Return True if event as been catched. |
|
433 | 456 | @rtype: boolean |
|
434 | 457 | ''' |
|
435 | ||
|
436 | 458 | if not self.AutoCompActive(): |
|
437 | 459 | if event.GetKeyCode() == wx.WXK_HOME: |
|
438 | 460 | if event.Modifiers == wx.MOD_NONE: |
General Comments 0
You need to be logged in to leave comments.
Login now