I have a Tkinter GUI that I want to spawn a subprocess and find out when the subprocess ends without waiting for the subprocess to terminate, which means that my GUI is still completely interactable / isn't frozen.
I have tried many methods such as the ones found in the following (mostly stackoverflow) links: 1, 2, 3, and 4.
I've found that I can't use any method that uses a for or while loop to read in the lines or that will end up with my GUI waiting for the loop to finish reading in everything. From what I've determined, I will need some kind of threading. However, using some of the examples through the links above don't seem to address my issue; for instance, adapting the code in [4] to work and make sense with my code would result in my GUI freezing until the program terminated.
Format of my code:
class MyClass(tk.Frame):
  def _init_(self,parent):
    # calls constructor of inherited class
    # other relevant code to initiate
    self.initUI()
  def runButtonFunction(self):
    # self.process = Popen(program_I_want_to_open)
    # ?? Need some way to determine when subprocess has 
    # exited so I can process the results created by that subprocess
  def stopButtonFunction(self):
    # terminates the subprocess created in run and its children at 
    # any moment subprocess is running 
  def initUI(self):
    # creates all UI widgets, one of which is a button starts the 
    # subprocess and another button that can terminate the subprocess
What approach should I be looking into to achieve the kind of functionality I want? Any conceptual advice, pseudocode, or actual examples of code would be very help.
I can clarify anything that doesn't make sense.
 
    