Quantcast

py2app wx.lib.pubsub.Publisher problem

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

py2app wx.lib.pubsub.Publisher problem

Hyeonseung I
Hi,

I`m trying to make an app bundle via py2app from a project using wxPython and it`s pub feature.
But there is a problem whenever running the app.

In my code, Publisher is imported as:
from wx.lib.pubsub import Publisher as pub

and use:
pub.subscribe(self.OnImageUpdated, 'image.updated')

But when I run the app, error message is in a console:
ImportError: cannot import name Publisher

I`ve tested many time with various method.

Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 14:13:39)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
>>> wx.version()
'2.8.12.0 (mac-unicode)'
>>> import wx.lib.pubsub as ppp
>>> ppp
<module 'wx.lib.pubsub' from '/usr/local/lib/wxPython-unicode-2.8.12.0/lib/python2.7/site-packages/wx-2.8-mac-unicode/wx/lib/pubsub/__init__.pyc'>
>>> ppp.Publisher
<wx.lib.pubsub.pub.PublisherClass instance at 0x1401a3f0>
>>>

Publisher is an instance of wx.lib.pubsub.pub.PublisherClass
In other word, Publisher is NOT a module.
But in the app bundle, python try to regard 'Publisher' as module. WHY?

So, I tried to change my code:
import wx.lib.pubsub as ppp
pub = ppp.Publisher
......
pub.subscribe(self.OnImageUpdated, 'image.updated')
.....

In this case, error massage is like this:
AttributeError: 'module' object has no attribute 'Publisher'

What`s the problem?

_______________________________________________
Pythonmac-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: py2app wx.lib.pubsub.Publisher problem

Chris Barker
On 9/16/11 8:37 PM, Hyeonseung I wrote:
> I`m trying to make an app bundle via py2app from a project using wxPython and it`s pub feature.
> But there is a problem whenever running the app.
>
> In my code, Publisher is imported as:
> from wx.lib.pubsub import Publisher as pub

...

> But when I run the app, error message is in a console:
> ImportError: cannot import name Publisher

> Publisher is an instance of wx.lib.pubsub.pub.PublisherClass
> In other word, Publisher is NOT a module.
> But in the app bundle, python try to regard 'Publisher' as module. WHY?

pubsub does some odd things in this regard.

There was a recent thread on the wxPython mailing list about this issue
-- I think the pubsub author came up with a patch. In that case it was
y2exe, but It's likely to be the same issue

You can also try the pubsub list.

-Chris



> So, I tried to change my code:
> import wx.lib.pubsub as ppp
> pub = ppp.Publisher
> ......
> pub.subscribe(self.OnImageUpdated, 'image.updated')
> .....
>
> In this case, error massage is like this:
> AttributeError: 'module' object has no attribute 'Publisher'
>
> What`s the problem?
>
> _______________________________________________
> Pythonmac-SIG maillist  -  [hidden email]
> http://mail.python.org/mailman/listinfo/pythonmac-sig
> unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG


--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

[hidden email]
_______________________________________________
Pythonmac-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: py2app wx.lib.pubsub.Publisher problem

Hyeonseung I
In reply to this post by Hyeonseung I
Thanks Werner, thanks Chris,

After many trials, it works. 

1. add 'packages' to options in setup.py

setup(
    app=APP,
    data_files=DATA_FILES,
    options={'py2app': {'argv_emulation': True, 'packages':['wx.lib.pubsub']}},
    setup_requires=['py2app'],
)

2. due to 'packages', wx.lib.pubsub is not able to be imported from code (not found module error), so change import lines to :
from pubsub import setuparg1
from pubsub import pub

3. insert a line:
publisher = pub.Publisher()

4. use it
publisher.subscribe(self.OnImageUpdated, 'image.updated')



2011. 9. 18., 오전 2:32, Werner F. Bruhin 작성:

On 09/17/2011 05:37 AM, Hyeonseung I wrote:
Hi,

I`m trying to make an app bundle via py2app from a project using wxPython and it`s pub feature.
But there is a problem whenever running the app.

In my code, Publisher is imported as:
from wx.lib.pubsub import Publisher as pub
Did you see the exchange some time ago on wxPython list?

Here a few of the threads Olivier pointed to in one of the messages: 
begin quote:

If this still doesn't work, try taking one of the py2exe examples for wxpython and adding the import pubsub in it and redo the py2exe. I recommend you try using the from pubsub import setupkwargs and see what happens with that. 
end quote:

Werner



_______________________________________________
Pythonmac-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Loading...