Skip to content

Commit

Permalink
Merge pull request #288 from hildogjr/master
Browse files Browse the repository at this point in the history
Enhacement #143 (flush to not freeze)
  • Loading branch information
hildogjr committed Jun 30, 2018
2 parents fdad239 + aec8910 commit 8e078a9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions kicost/kicost_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ def kicost_gui(files=None):
app = wx.App(redirect=False)
frame = formKiCost(None)

class GUILoggerHandler(object):
class GUI_LoggerHandler(object):
def __init__(self, aWxTextCtrl):
#super(self.__class__, self).__init__()
self.area = aWxTextCtrl
Expand All @@ -1059,8 +1059,10 @@ def write(self, msg):
# Necessary the call bellow and not above
# because of the KiCost threads.
wx.CallAfter(self.area.AppendText, msg)
def flush(self):
sys.__stdout__.flush()

class GUIetaHandler(object):
class GUI_ETAHandler(object):
def __init__(self):
pass
def write(self, msg):
Expand All @@ -1076,10 +1078,12 @@ def write(self, msg):
re.findall('\|+?\s(.*)$', msg)[0] ) # Eta.
except:
sys.__stderr__.write(msg)
def flush(self):
sys.__stderr__.flush()

# Redirect the logger to the GUI area.
sys.stdout = GUILoggerHandler(frame.m_textCtrl_messages)
sys.stderr = GUIetaHandler()
sys.stdout = GUI_LoggerHandler(frame.m_textCtrl_messages)
sys.stderr = GUI_ETAHandler()


#if files:
Expand Down

0 comments on commit 8e078a9

Please sign in to comment.