I make some changes and test it. It looks like multiprocessing not able to run inside wx Frame. My purpose is after clicking the button, function_1 will be started in a separate process and the control will turn back to wx Frame MainLoop so I can continue to do other things like making changes in the grid, don't need to wait 2 minutes. is it possible? Thanks.
import time import wx.grid from multiprocessing import Process class Frame(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, title="Multiprocessing", size=(600, 500), pos = (300, 300)) wx.Panel(self) self.SetBackgroundColour("Blue") grid = wx.grid.Grid(self, size=(400,100), pos=(100,100)) grid.CreateGrid(3,3) for c in range(3): grid.SetColSize(c,100) for r in range(3): grid.SetRowLabelValue(r,time.strftime('%H:%M:%S')) for c in range(3): grid.SetCellValue(r, c, "R"+str(r)+"/C"+str(c)) runButton = wx.Button(self, label="Run it", pos=(250, 250)) runButton.Bind(wx.EVT_BUTTON, self.onClick) def onClick(self,event): ## p = Process(target=self.function_1) ## p.start() self.function_1() print('function_1 run 2 minutes and return result.') def function_1(self): time.sleep(120) if __name__ == "__main__": app = wx.App() win = Frame() win.CreateStatusBar() win.Show() app.MainLoop()