【发布时间】:2014-10-21 05:44:56
【问题描述】:
为了让这个进程多线程化,我已经奋斗了三个小时,这样我就可以显示一个进度框了。我终于让它工作了,因为该过程按预期完成,并且所有函数都调用了,包括更新窗口上的进度指示器的函数。
但是,窗口从未真正显示。这是在 Glade 中设计的 PyGObject 接口。我不开心。
def runCompile(obj):
compileWindow = builder.get_object("compilingWindow")
compileWindow.show_all()
pool = ThreadPool(processes=1)
async_result = pool.apply_async(compileStrings, ())
output = async_result.get()
#output = compileStrings() #THIS IS OLD
compileWindow.hide()
return output
正如我所提到的,一切正常,除了窗口没有出现。即使我消除了 compileWindow.hide() 命令,在该过程完成之前,窗口也不会显示。事实上,整个愚蠢的程序都会冻结,直到进程完成。
我已经走到了尽头。帮忙?
(顺便说一句,使用生成器的“推荐”过程不起作用,因为我必须从“漫长的过程”中得到回报。)
【问题讨论】:
标签: python multithreading python-3.x pygobject