Luces = Reflejos = Paredes = [] lucesEfectivas = [[0]*500]*500 Img = None def threadPathTrace(): PT.pathTrace(Luces, Reflejos, Paredes, Img, lucesEfectivas) t = threading.Thread(target = threadPathTrace) # f being the function that tells how the ball should move t.setDaemon(True) # Alternatively, you can use "t.daemon = True" if __name__ == '__main__': display = None Thread = threading.Thread(target=MAINLOOP) Thread.setDaemon(True) boolean = True display = Window(500, 500, "Path Tracing") Thread.start() display.run()