Multithreading wxpython线程化任务并更新GUI

Multithreading wxpython线程化任务并更新GUI,multithreading,wxpython,Multithreading,Wxpython,我有一些简单的wxpython GUI,当我单击一个按钮时,我想在另一个线程中运行一些io任务,以便在io线程运行时不阻塞GUI并相应地更新GUI,例如从io线程将标签更新为:[io任务完成百分比]% 但是,有时这会起作用,有时会引发异常: The program 'python2.7' received an X Window System error. This probably reflects a bug in the program. The error was 'RenderBadP

我有一些简单的wxpython GUI,当我单击一个按钮时,我想在另一个线程中运行一些io任务,以便在io线程运行时不阻塞GUI并相应地更新GUI,例如从io线程将标签更新为:[io任务完成百分比]%

但是,有时这会起作用,有时会引发异常:

The program 'python2.7' received an X Window System error.
This probably reflects a bug in the program.
The error was 'RenderBadPicture (invalid Picture parameter)'.
  (Details: serial 14127 error_code 163 request_code 149 minor_code 7)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the --sync command line
   option to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)
使用-sync命令运行程序会产生以下错误:

[xcb] Unknown request in queue while dequeuing
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
我已经读到,不允许从创建GUI的线程之外的其他线程更新GUI线程,但是如果是这样,如何完成这个简单的任务?从另一个线程更新GUI


谢谢

这里已经有很多关于这个主题的帖子了,wxpython wiki上也有详细介绍。查找wx.CallAfter。

这里已经有很多关于这个主题的线程,wxpython wiki上也有详细介绍。查找wx.CallAfter。

谷歌搜索wxpythonwiki会给出结果,谢谢:不过你知道一些使用队列和计时器的源代码吗?我想用他们来验证我的推理。谷歌搜索wxpythonwiki给出了结果,谢谢:但是你知道一些使用队列和计时器的来源吗?我想和他们核实我的推理。