@@ -142,10 +142,6 @@ def __init__(self,
142142 self .SetSizer (self .sizer )
143143 self .Layout ()
144144
145- # set font
146-
147- self .txtTerm .SetMargins (8 )
148-
149145 # capture keypresses
150146 if wx .Platform == '__WXMAC__' or wx .Platform == '__WXMSW__' :
151147 # need to use this on MacOS and Windows
@@ -180,8 +176,9 @@ def __init__(self,
180176 self .txtTerm .WriteText ("Hit [Return] to start a Python session." )
181177 self ._lastTextPos = self .txtTerm .GetLastPosition ()
182178
183- # Setup fonts
179+ # Setup fonts and margins
184180 self .setFonts ()
181+ self .txtTerm .SetMargins (8 )
185182
186183 def setFonts (self ):
187184 """Set the font for the console."""
@@ -198,7 +195,7 @@ def onTerminate(self, event):
198195 self .txtTerm .Clear ()
199196 self .txtTerm .WriteText ("Hit [Return] to start a Python shell." )
200197 self ._lastTextPos = self .txtTerm .GetLastPosition ()
201-
198+ self . setFonts ()
202199 self .toolbar .update ()
203200
204201 @property
@@ -231,16 +228,19 @@ def getPid(self):
231228 """Get the process ID for the active interpreter (`int`)."""
232229 return self ._pid
233230
234- def getPwd (self ):
235- """Get the present working directory for the interpreter."""
236- pass
237-
238- def setPwd (self ):
239- """Set the present working directory for the interpreter."""
240- pass
231+ # def getPwd(self):
232+ # """Get the present working directory for the interpreter.
233+ # """
234+ # pass
235+ #
236+ # def setPwd(self):
237+ # """Set the present working directory for the interpreter.
238+ # """
239+ # pass
241240
242241 def getNamespace (self ):
243- """Get variable names in the current namespace."""
242+ """Get variable names in the current namespace.
243+ """
244244 self .push ('dir()' ) # get namespace values
245245
246246 def onIdle (self , event ):
@@ -260,6 +260,10 @@ def onIdle(self, event):
260260 # we have new characters
261261 newChars = False
262262
263+ # reset
264+ stdin_text = ''
265+ stderr_text = ''
266+
263267 # check if we have input text to process
264268 if self ._process .IsInputAvailable ():
265269 stdin_text = self ._process .InputStream .read ()
@@ -292,10 +296,9 @@ def onIdle(self, event):
292296 # boundary of the editable area.
293297 if newChars :
294298 self ._lastTextPos = self .txtTerm .GetLastPosition ()
295- self .txtTerm .ShowPosition (self ._lastTextPos )
296299 self .txtTerm .SetInsertionPoint (- 1 )
297-
298- self .txtTerm . _applyAppTheme ()
300+ self . txtTerm . ShowPosition ( self . _lastTextPos )
301+ # self.setFonts() # update fonts
299302
300303 def resetCaret (self ):
301304 """Place the caret at the entry position if not in an editable region.
@@ -321,7 +324,8 @@ def push(self, lines):
321324 self .submit (line )
322325
323326 def submit (self , line ):
324- """Submit the current line to the interpreter."""
327+ """Submit the current line to the interpreter.
328+ """
325329 if not self .isStarted :
326330 return
327331
@@ -334,7 +338,8 @@ def submit(self, line):
334338 self ._isBusy = True
335339
336340 def start (self , evt = None ):
337- """Start a new interpreter process."""
341+ """Start a new interpreter process.
342+ """
338343 if self .isStarted : # nop if started already
339344 self .toolbar .update ()
340345 return
@@ -371,48 +376,56 @@ def start(self, evt=None):
371376 self ._lastTextPos = self .txtTerm .GetLastPosition ()
372377 self .toolbar .update ()
373378
374- self .txtTerm . _applyAppTheme ()
379+ self .setFonts ()
375380 wx .EndBusyCursor ()
376381
377382 def interrupt (self , evt = None ):
378- """Send a keyboard interrupt signal to the interpreter."""
383+ """Send a keyboard interrupt signal to the interpreter.
384+ """
379385 if self .isStarted :
380386 os .kill (self ._pid , wx .SIGINT )
381387 self .toolbar .update ()
382388
383389 def close (self , evt = None ):
384- """Close an open interpreter."""
390+ """Close an open interpreter.
391+ """
385392 if self .isStarted :
386393 os .kill (self ._pid , wx .SIGTERM )
387394
388395 def restart (self , evt = None ):
389- """Close the running interpreter (if running) and spawn a new one."""
396+ """Close the running interpreter (if running) and spawn a new one.
397+ """
390398 self .close ()
391399 self .start ()
392400
393401 def clear (self , evt = None ):
394- """Clear the contents of the console."""
402+ """Clear the contents of the console.
403+ """
395404 self .txtTerm .Clear ()
396405 self ._lastTextPos = self .txtTerm .GetLastPosition ()
397406 self .push ('' )
407+ self .setFonts ()
398408
399409 def onMaxLength (self , event ):
400- """What to do if we exceed the buffer size limit for the control."""
410+ """What to do if we exceed the buffer size limit for the control.
411+ """
401412 event .Skip ()
402413
403414 def __del__ (self ):
404415 pass
405416
406417 def clearAndReplaceTyped (self , replaceWith = '' ):
407- """Clear any text that has been typed."""
418+ """Clear any text that has been typed.
419+ """
408420 self .txtTerm .Remove (self ._lastTextPos , self .txtTerm .GetLastPosition ())
409421 if replaceWith :
410422 self .txtTerm .WriteText (replaceWith )
411423
412424 self .txtTerm .SetInsertionPoint (self .txtTerm .GetLastPosition ())
413425
414426 def getTyped (self ):
415- """Get the text that was typed or is editable (`str`)."""
427+ """Get the text that was typed or is editable (`str`).
428+ """
416429 return self .txtTerm .GetRange (
417430 self ._lastTextPos ,
418431 self .txtTerm .GetLastPosition ())
@@ -426,6 +439,7 @@ def onChar(self, event):
426439 if event .GetKeyCode () == wx .WXK_RETURN :
427440 self .start ()
428441
442+ event .Skip ()
429443 return
430444
431445 # if self._isBusy: # dont capture events when busy
@@ -467,8 +481,6 @@ def onChar(self, event):
467481 if self ._history :
468482 self ._historyIdx = - 1
469483
470- self .txtTerm ._applyAppTheme ()
471-
472484 event .Skip ()
473485
474486 def _applyAppTheme (self ):
0 commit comments