Jul-10-2019, 12:48 AM
(Jul-08-2019, 10:22 PM)abi17124 Wrote: What I would like is to for the GUI to be running while the edit function executes instead of freezing, and also in the future, to pause/continue the editing at any given time with buttons I intend to add into the GUI.
You've run into the classic problem of trying to do a lot of CPU or wall-clock intensive operations. When your program begins to take so much of the processor that you "starve" your GUI of CPU cycles, it's then that you turn to Threads to get yourself out of the problem.
To get through this, you need to startup threads at places where your operations will block for a long time. This program is a demonstration of how to do that with PySimpleGUI:
https://repl.it/@PySimpleGUI/Threaded-fo...long-tasks
You can also run it there and see how it works. To use it just type in the number of seconds you want your function to take and press the button to start it. While that thread is "busy" doing work (sleeping) notice how you can continue to take input from the GUI and act on it.
There's little of your code that you need to change other than to start a thread instead of call a function. If you need to know when the operation completes, then communicate through a queue like in the demo.