##// END OF EJS Templates
Deal with raw_input.
Gael Varoquaux -
Show More
@@ -221,7 +221,7 b' class ConsoleWidget(editwindow.EditWindow):'
221 self.GotoPos(self.GetLength())
221 self.GotoPos(self.GetLength())
222 wx.Yield()
222 wx.Yield()
223
223
224
224
225 def new_prompt(self, prompt):
225 def new_prompt(self, prompt):
226 """ Prints a prompt at start of line, and move the start of the
226 """ Prints a prompt at start of line, and move the start of the
227 current block there.
227 current block there.
@@ -26,6 +26,7 b' import re'
26 from wx import stc
26 from wx import stc
27 from console_widget import ConsoleWidget
27 from console_widget import ConsoleWidget
28 import __builtin__
28 import __builtin__
29 from time import sleep
29
30
30 from IPython.frontend.prefilterfrontend import PrefilterFrontEnd
31 from IPython.frontend.prefilterfrontend import PrefilterFrontEnd
31
32
@@ -118,6 +119,23 b' class IPythonWxController(PrefilterFrontEnd, ConsoleWidget):'
118 self.pop_completion(completions, offset=offset)
119 self.pop_completion(completions, offset=offset)
119
120
120
121
122 def raw_input(self, prompt):
123 """ A replacement from python's raw_input.
124 """
125 self.new_prompt(prompt)
126 self.waiting = True
127 self.__old_on_enter = self._on_enter
128 def my_on_enter():
129 self.waiting = False
130 self._on_enter = my_on_enter
131 # Busy waiting, ugly.
132 while self.waiting:
133 wx.Yield()
134 sleep(0.1)
135 self._on_enter = self.__old_on_enter
136 return self.get_current_edit_buffer().rstrip('\n')
137
138
121 def execute(self, python_string, raw_string=None):
139 def execute(self, python_string, raw_string=None):
122 self.CallTipCancel()
140 self.CallTipCancel()
123 self._cursor = wx.BusyCursor()
141 self._cursor = wx.BusyCursor()
@@ -133,7 +151,10 b' class IPythonWxController(PrefilterFrontEnd, ConsoleWidget):'
133 #self.SetSelection(self.GetLength()-1, self.GetLength())
151 #self.SetSelection(self.GetLength()-1, self.GetLength())
134 #self.ReplaceSelection('')
152 #self.ReplaceSelection('')
135 self.GotoPos(self.GetLength())
153 self.GotoPos(self.GetLength())
154 self.__old_raw_input = __builtin__.raw_input
155 __builtin__.raw_input = self.raw_input
136 PrefilterFrontEnd.execute(self, python_string, raw_string=raw_string)
156 PrefilterFrontEnd.execute(self, python_string, raw_string=raw_string)
157 __builtin__.raw_input = self.__old_raw_input
137
158
138
159
139 def after_execute(self):
160 def after_execute(self):
General Comments 0
You need to be logged in to leave comments. Login now