In the wxPython world, there are three related “threadsafe” methods. If you do not use one of these three when you go to update your user interface, then you may experience weird issues. Sometimes your GUI will work just fine. Other times, it will crash Python for no apparent reason. Thus the need for the threadsafe methods: wx.PostEvent, wx.CallAfter and wx.CallLater.
简而言之,您可以在发布对象上创建接收器:
from wx.lib.pubsub import Publisher
Publisher().subscribe(update_function, 'update') # Params: callback, event name
它不是线程安全的。引用这个优秀的blog post:
简而言之,您可以在发布对象上创建接收器:
然后从线程中使用^{} :
^{pr2}$尽管如此,如果您只想在进程之间共享变量,请使用supported way of doing this。目前,您正在滥用GUI工具箱来保存变量,而应该使用内置类型来保存变量。正确地共享这些数据,并使用GUI显示数据。在
相关问题 更多 >
编程相关推荐