将wxPython对象作为多处理器参数传递 [英] Passing wxPython objects as multiprocessor arguments
问题描述
我目前正在使用wxpython用gui编写python程序.该程序具有评估多个pythonscripts的功能,因此将挂断gui.我正在尝试为此功能使用单独的过程.问题在于该函数需要ui中的一些内容; listctrl和textctrl,以更新有关已运行脚本的信息.尝试将wxpython对象传递给进程时收到以下错误
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()
推荐答案
基本上,您不能.您需要将结果传回,并让GUI线程更新listctrl
和textctrl
.
Basically, you can't. You need to pass the results back and let the GUI thread update the listctrl
and textctrl
.
请参见此邮件列表线程有关酸洗错误的信息.
See this mailing list thread for information about the pickling error.
这篇关于将wxPython对象作为多处理器参数传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!