MVP and pubsub?

Hi Werner,

Werner F. Bruhin пишет:

Hi Basil,

Basil Shubin wrote:

Merry Christmas!

I'll trying to use pubsub in my MVP redesigned application, but fail in some place. Please, examine attached source code. In a module 'data/wordinteractor.py' I have add Publisher.sendMessage call and want to recive it in a 'data/meaningpresenter.py', but that's doesn't happened. My the task is: on each item selection in 'Word' list should happen some events in a 'Meaning' list. I decide to 'wx.lib.pubsub' for this, but I am unable to get it wotking.

You are not instantiating the Presenter.

I put the attached module into your test folder and then changed the imports from

from wx.lib.pubsub import Publisher

to

import mypublisher as mypub

and this

Publisher.subscribe

to
mypub.publisher.subscribe

Thanks for reply. You test code works excellent. But problem is that I want subscribe to message inside MeaningInteractor class and process catched message here, but with a code I wrote (attachment) it's not working :frowning: Yes I can successfuly call MyPrint from data/publisher.py in MeaningInteractor, but the same function placed inside MeaningPublisher won't process :frowning:

I'm totally confused here. Please, needs your help.

Thanks for any help.

testapp.zip (7.31 KB)

Hi Basil,

Basil Shubin wrote:

Hi Werner,

Werner F. Bruhin пишет:

So, I think it has something to do with what is mentioned in wx.lib.pubsub.py doc string for subscribe (around line 637), i.e. there is no hard reference for MeaningInteractor.

After I add:

self.viewer = MeaningViewer(self.parent, sizer)
self.interactor = MeaningInteractor()
MeaningPresenter(None, self.viewer, self.interactor)

in WordViewer class it starts working! Thanks for the clue!

Ah, I did not do the "self.", - stupid me!

But I can't figure it out. Hopefully someone with better know how will enlighten us.

But I still don't understand why it's works for:

presenter.WordPresenter(model.getDemoWords(), viewer.WordViewer(self),
                        interactor.WordInteractor())

in a MainFrame class??? Any idea?

You only do sendMessage in the WordInteractor, there is no subscribe in there, is there?

Werner

···

Anyway big thanks!

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org