diff --git a/HISTORY.rst b/HISTORY.rst index 2529659bf..58f21b0e1 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -7,6 +7,7 @@ ______________________ * Fixed some Python 2 incompatibility of the GUI and Altium module. * Fixed the tqdm print channel. Now the process bar is kept at the end. +* Fixed the output messages when used the GUI. * Fixed GUI problem caused by distributors re-factore and other UI improvements. * More improvements on scrape classes. * Now TME ajax post scrape method repect the `fake_browser`. diff --git a/kicost/kicost_gui.py b/kicost/kicost_gui.py index edbe98483..baf714545 100644 --- a/kicost/kicost_gui.py +++ b/kicost/kicost_gui.py @@ -1052,27 +1052,20 @@ def __init__(self, aWxTextCtrl): #super(self.__class__, self).__init__() self.area = aWxTextCtrl def write(self, msg): - try: - self.area.AppendText(msg) - sys.__stdout__.flush() - except: - # In case of freeze GUI, print on terminal to allow debug. - sys.__stdout__.write(msg) - #finally: - # self.flush() - #def flush(self): - # sys.__stdout__.flush + #self.area.AppendText(msg) + # Necessary the call bellow and not above + # because of the KiCost threads. + wx.CallAfter(self.area.AppendText, msg) # Redirect the logger to the GUI area. - #sys.stdout = GUILoggerHandler(frame.m_textCtrl_messages) + sys.stdout = GUILoggerHandler(frame.m_textCtrl_messages) #sys.stderr = GUILoggerHandler(frame.m_textCtrl_messages) - #TODO when the above works, change all print and `m_textCtrl_messages.Append` on GUI to logging. frame.Show() app.MainLoop() # Restore the channel print output to terminal. - # Necessary if KiCost was called by other software? Normal execution ends here. + # Necessary if KiCost was called by other software? sys.stdout = sys.__stdout__ sys.stdout = sys.__stderr__