Nait
Nait

Reputation: 1155

Passing wxPython objects as multiprocessor arguments

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()

Upvotes: 2

Views: 475

Answers (1)

agf
agf

Reputation: 176980

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.

Upvotes: 2

Related Questions