Jul-02-2020, 03:37 PM
Hi guys! I have this program which displays the time. The time is updated via a multiprocessing Process() which is targeted at a partial. However, the partial's function is supposed to set the value of a tkinter StringVar(). But, I get this error:
The code:
I would be grateful if anyone can help :
.
Error:Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\joshu\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 1883, in __call__
return self.func(*args)
File "C:/Users/joshu/Downloads/OrderLog.py", line 198, in sign_in_func
main_app()
File "C:/Users/joshu/Downloads/OrderLog.py", line 1074, in main_app
time_process.start()
File "C:\Users\joshu\AppData\Local\Programs\Python\Python38-32\lib\multiprocessing\process.py", line 121, in start
self._popen = self._Popen(self)
File "C:\Users\joshu\AppData\Local\Programs\Python\Python38-32\lib\multiprocessing\context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "C:\Users\joshu\AppData\Local\Programs\Python\Python38-32\lib\multiprocessing\context.py", line 326, in _Popen
return Popen(process_obj)
File "C:\Users\joshu\AppData\Local\Programs\Python\Python38-32\lib\multiprocessing\popen_spawn_win32.py", line 93, in __init__
reduction.dump(process_obj, to_child)
File "C:\Users\joshu\AppData\Local\Programs\Python\Python38-32\lib\multiprocessing\reduction.py", line 60, in dump
ForkingPickler(file, protocol).dump(obj)
TypeError: cannot pickle '_tkinter.tkapp' object
I'm using PyCharm as my editor.The code:
now = datetime.datetime.now() time_var = StringVar() time_set_partial = partial(time_var.set, str(now.hour) + ":" + str("%02d" % now.minute).format(1)) time_process = Process(target = time_set_partial) time_process.start() time_of_day = Label(textvariable = time_var) time_of_day.pack()I think the issue lies somewhere within the time_set_partial = partial(time_var.set, str(now.hour) + ":" + str("%02d" % now.minute).format(1)) line but I'm not sure.
I would be grateful if anyone can help :
![Smile Smile](https://python-forum.io/images/smilies/smile.png)