title: How can I prevent gui freezing in wxpython?
body: <p><strong>[PROBLEM]</strong>
  If I click on a button that triggers a function then gui will freeze until the function concludes.</p>
  
  <p><strong>[CODE]</strong></p>
  
  <pre><code>import wx
  app = wx.App(redirect=False)
  top = wx.Frame(None)
  top.Maximize(True) # Set to maximize the application
  sizer = wx.GridBagSizer()
  
  def testFunction(event):
      import pyautogui
      import time
      pyautogui.FAILSAFE = False
      for i in range(2):
              pyautogui.hotkey('win','r')
              time.sleep (0.5)
              pyautogui.typewrite('cmd.exe')
              time.sleep (0.5)
              pyautogui.hotkey('enter')
              time.sleep (0.5)
              time.sleep (3)
  
  
  addButton = wx.Button( top, -1, "Start", style=wx.BU_EXACTFIT )
  sizer.Add(addButton, (6, 8), (2, 14), wx.EXPAND)
  top.Bind(wx.EVT_BUTTON, testFunction, addButton)
  top.Sizer = sizer
  top.Sizer.Fit(top)
  top.Show()
  app.MainLoop()
  </code></pre>
  
  <p>[CURRENT]
  The gui freezes until the function ends.</p>
  
  <p>[DESIRED]
  The gui should not freeze.
  Note: I think that is related to threads but I cannot quite grasp this concept. </p>