lmoura
1/23/2019 - 9:21 AM

Thread

def saveBook(self):
    #Show GIF
    root.saved.gif.on()
    #Update frame
    GLOB.app.processEvents()
    #Save on separate thread to allow interface to remain active
    t = threading.Thread(target=self.saveThread)
    t.start()

def saveThread(self): #this function runs in background, allowing GIF to run in main thread
    #Prevent multiple threads from queueing to save the file
    if not self.lock.acquire(False):
        return
    self.b.save(self.file)
    #Remove GIF
    root.saved.gif.off()
    self.lock.release()