将 wxPython 对象作为多处理器参数传递
我目前正在使用 wxpython 用 gui 编写一个 python 程序。该程序有一个函数可以评估多个 python 脚本,因此会挂起 gui。我正在尝试为此功能使用单独的进程。问题是该函数需要 ui 中的一些东西; listctrl 和 textctrl,用于更新有关已运行的脚本的信息。尝试将 wxpython 对象传递给进程时收到以下错误
PicklingError: Can't pickle <type 'PySwigObject'>: attribute lookup __builtin__.PySwigObject failed
创建并启动进程的方法:
def CreateProcess():
q = Queue()
q.put(gui.caselist)
q.put(gui.textlog)
p = Process(target=runScripts, args=(q,))
p.start()
进程正在运行的方法的一部分:
def runScripts(q):
caselist = q.get()
text = q.get()
I'm currently writing a program in python with a gui using wxpython. The program has a function which evaluates several pythonscripts and will therefore hang up the gui. I am trying to use a separate process for this function. The problem is that the function needs a few things from the ui; a listctrl and a textctrl, to update the information about the scripts that have been run. The following error is received when trying to pass wxpython objects to the process
PicklingError: Can't pickle <type 'PySwigObject'>: attribute lookup __builtin__.PySwigObject failed
Method that creates and starts the process:
def CreateProcess():
q = Queue()
q.put(gui.caselist)
q.put(gui.textlog)
p = Process(target=runScripts, args=(q,))
p.start()
Part of the method that is being ran by the process:
def runScripts(q):
caselist = q.get()
text = q.get()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本上,你不能。您需要将结果传回并让 GUI 线程更新
listctrl
和textctrl
。请参阅此邮件列表线程有关酸洗错误的信息。
Basically, you can't. You need to pass the results back and let the GUI thread update the
listctrl
andtextctrl
.See this mailing list thread for information about the pickling error.