My problem is similar to what was asked here: Cannot 'pickle' a Tkinter object in a multiprocessing environment in Windows
Unfortunately i don't quite understand how to pass a target function into the subprocess class which is created. And if possible i would like to pass arguments and get returns of that function (optional). I basically just copied the code from the question above. Just for reference, this is the code: (not my code at all)
import multiprocessing
from tkinter import *
from queue import Empty
class Subprocess(multiprocessing.Process):
def __init__(self):
multiprocessing.Process.__init__(self)
self.queue = multiprocessing.Queue()
def run(self):
self.root = Tk()
self.root.after(100, self._check_queue) # Check the queue every 100ms
self.root.mainloop()
def _check_queue(self):
try:
out = self.queue.get_nowait()
if out == 'stop':
self.do_stop()
return
except Empty:
pass
self.root.after(100, self._check_queue)
def stop(self):
self.queue.put('stop')
def do_stop(self):
self.root.destroy()