I spent 2 days to try on Windows 7 / 10 and x64 / x32; cut the code to minimum and remove all calls to timer & sleep but still crash with stop message (Not Responding) "Python has stopped working. A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available." when not calling the thread, it seems ok. since the function code is kind of long. Let me know if need, I will post. I use python 3.6.2. Thanks.
import wx import wx.grid import pandas as pd import googlefinance.client as gf from threading import * class RunThread(Thread): def __init__(self, event, win): Thread.__init__(self) self.stopped = event self.start() def run(self): print('Loading 0,0 ..') #win.Update_5M(0, 0) while True: print('Loading 1,12 ..') #win.Update_5M(1, 12) self.stopped.wait(20) class Frame(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, title="Thread Crash", size=(530, 742), pos = (500, 100)) wx.Panel(self) sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(sizer) self.grid = self.Create_Grid() stopFlag = Event() RunThread(stopFlag, self) def Update_5M(self, n, m): self.dfg, self.dfr = self.Load_Data_Frame(n) self.Update_Grid(self.dfr, self.grid, 'red', m) self.Update_Grid(self.dfg, self.grid, 'green', m) def Create_Grid(self): self.colno = 11 self.colsz = [43,40,22,40,44,60,40,40,40,40,40] grid = wx.grid.Grid(self, size=(522, 700), pos=(0,0)) grid.CreateGrid(1,11) grid.SetRowLabelSize(60) grid.SetLabelFont(wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL)) grid.SetDefaultCellAlignment(wx.ALIGN_RIGHT,wx.ALIGN_CENTRE) for col in range(self.colno): grid.SetColSize(col,self.colsz[col]) return grid if __name__ == "__main__": app = wx.App() win = Frame() win.Show() app.MainLoop()