Python多处理-TypeError:无法pickle'_tkinter.tkapp';对象
我正在尝试使用python和Tkinter进行简单的多处理。但我收到了错误Python多处理-TypeError:无法pickle'_tkinter.tkapp';对象,python,python-3.x,tkinter,multiprocessing,Python,Python 3.x,Tkinter,Multiprocessing,我正在尝试使用python和Tkinter进行简单的多处理。但我收到了错误 Exception in Tkinter callback ... ... ForkingPickler(file, protocol).dump(obj) TypeError: cannot pickle '_tkinter.tkapp' object 程序很简单。运行后,它会打开一个窗口(开始页面),我在那个里点击按钮,它会将我重定向到实验页面,在那个里我点击按钮,一切都开始了 class experime
Exception in Tkinter callback
...
...
ForkingPickler(file, protocol).dump(obj)
TypeError: cannot pickle '_tkinter.tkapp' object
程序很简单。运行后,它会打开一个窗口(开始页面),我在那个里点击按钮,它会将我重定向到实验页面,在那个里我点击按钮,一切都开始了
class experimentPage(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
# start experiment on click
self.button2 = tk.Button(self, text="Ready",
command=self.logic)
self.button2.pack()
def proc1(self):
while True:
print("LOL1")
def proc2(self):
while True:
print("LOL2")
def proc3(self):
while True:
print("LOL3")
def logic(self):
t1 = multiprocessing.Process(target=self.proc1)
t2 = multiprocessing.Process(target=self.proc2)
t3 = multiprocessing.Process(target=self.proc3)
t1.start()
t2.start()
t3.start()
t1.join()
t2.join()
t3.join()
这是我的主要任务
class Main(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
container = tk.Frame(self)
self.attributes('-fullscreen', True)
container.pack(side="top", fill="both", expand = True)
container.grid_rowconfigure(0, weight=1)
container.grid_columnconfigure(0, weight=1)
self.frames = {}
for F in (startPage.startPage, experimentPage.experimentPage):
frame = F(container, self)
self.frames[F] = frame
frame.grid(row=0, column=0, sticky="nsew")
self.show_frame(startPage.startPage)
def show_frame(self, cont):
frame = self.frames[cont]
frame.tkraise()
app = Main()
app.mainloop()
我就是做不到。感谢您的帮助。多处理使用
多处理.Queue
在进程之间交换信息。此队列实现使用pickle
对信息进行序列化和反序列化
有些对象,包括tkinter的应用程序,是不可拾取的
请参阅问题以供参考。对我来说,这似乎更像是一个评论,而不是一个答案。谢谢,这只是我的学士学位论文,所以它不是世界末日:D,但我可以在一个核心上获得足够的数据,所以我会保持原样。谢谢你的回答。