pyinstaller exe with pubsub
I have written a wxpython application that uses several different threads
all of which need to write to the log window (textctrl box). Because of
this I followed this tutorial
http://www.blog.pythonlibrary.org/2010/05/22/wxpython-and-threads/
And used wx.CallAfter and PubSub.
This was my original code
from wx.lib.pubsub import Publisher
Publisher().subscribe(self.messenger, "update")
wx.CallAfter(Publisher().sendMessage, "update", "Thread finished!")
def messenger(self, msg):
self.logtxtctrl.WriteText(msg.data)
this code worked brilliantly and thought it would be easy to use
pyinstaller to create an exe for my code.
How wrong was I!!
So after reading some comments it seems there are two versions of the
pubSub API, so using this
http://wiki.wxpython.org/WxLibPubSub
I tweaked my code to the following
from wx.lib.pubsub import setuparg1
from wx.lib.pubsub import pub
pub.subscribe(self.messenger, "update")
wx.CallAfter(pub.sendMessage, "update", data="Program success")
def messenger(self, data):
self.logtxtctrl.WriteText(data)
This code now works and again I tried to use pyinstaller and still no luck.
So i then read the following articles
How to get pubsub to work with pyinstaller?
http://www.pyinstaller.org/ticket/312
Both of which were very useful and I tried all the different variations of
changing the hook files and different spec files, I still cannot get it to
work.
These posts are almost 2 years ago and I would have thought adding pubsub
would be solved.
Can anyone please explain the process of what hooks I need, what to have
in a spec file and other elements I need to do to get it to work?
if there is no solution how else can I do thread safe communications to
widgets?
No comments:
Post a Comment