Queue
を作成して、別のプロセスに渡すことができます。
from multiprocessing import Process, Queue
def f(q):
q.put([42, None, 'hello'])
if __name__ == '__main__':
q = Queue()
p = Process(target=f, args=(q,))
p.start()
print q.get() # prints "[42, None, 'hello']"
p.join()
例:Python Docsからwx.py.shell.Shell Docsでconstructurパラメータは、私はそれを試していないが、locals
は、ローカル変数の辞書であるかもしれない、あなたができる
__init__(self, parent, id, pos, size, style, introText, locals,
InterpClass, startupScript, execStartupScript, *args, **kwds)
として与えられていますシェルに渡します。だから、私は次のことをしようとするだろう:
def f(cmd_queue):
shell = wx.py.shell.Shell(parent, id, pos, size, style, introText, locals(),
...)
q = Queue()
p = Process(target=f, args=(q,))
p.start()
をシェルの内部では、あなたがして実行する親プロセスで読み取ることが続いていcmd_queue
にあなたのコマンドを置くことができるはずです。
あなたはさらに質問をしてくれますか? – kcwu
通常、wx.py.shell.Shellを作成すると、GUIを実行しているPythonの現在のプロセスにコマンドが送信されます。コマンドを私が作成した別のプロセスに進めたい。 –