Hi all,
Having trouble getting a "subscribe" to take. This is a wxPython app but I am using pubsub directly. I'm using Wing on Win 7 with Python 2.7.3.
I have a main module that sets up the app.MainLoop, a module that has all the wxPython code (actually two, I'm using wxFormBuilder so there is their output module and then mine for all my event code, etc.), a module with the topic tree classes and another module for other processing tasks.
If I set a breakpoint on "pub.subscribe(self.search, "agile.search")" in my processing module, the subscription works, self.search gets the message. If I don't set a breakpoint, self.search doesn't get the message? I setup a listener on pub.ALL_TOPICS and the message is always going out. If I put "printTreeDocs(extra='L')" right after the subscribe, the printed tree shows the listener, but the one right before going into app.MainLoop() doesn't show it.
Weak reference problem? Looks like the listener goes away for some reason. Guessing this is a basic Python problem that I'm missing...
The topic tree prints fine so I'm skipping showing it.
Thanks for the help,
Eric
========================================================================
Main module:
========================================================================
import wx
from pubsub import pub
from pubsub.utils.topictreeprinter import printTreeDocs
import uiclass
import pubsubstuff
import processing
########################################################################
class Main(object):
""""""
#----------------------------------------------------------------------
def __init__(self):
"""Display the GUI"""
proc = processing.Processing()
uiclass.UIclass(None).Show()
if __name__ == "__main__":
app = wx.App(False)
pub.importTopicTree(pubsubstuff)
pub.exportTopicTree('kwargs_topics_out')
pub.setTopicUnspecifiedFatal()
Main()
printTreeDocs(extra='L') # the search listener isn't shown
app.MainLoop()
========================================================================
uiclass ("wrapper for the wxFormBuilder output")
========================================================================
from pubsub import pub
# wxFormBuilder output
import wxAgileHistory
# Create main GUI
class UIclass(wxAgileHistory.fraMain):
def __init__(self, parent):
wxAgileHistory.fraMain.__init__(self, parent)
pub.subscribe(self.init_app, "app.init") # this always works
========================================================================
processing (misc functions, the app interacts with a webpage
========================================================================
from pubsub import pub
from pubsub.utils.topictreeprinter import printTreeDocs
########################################################################
class Processing(object):
""""""
#----------------------------------------------------------------------
def __init__(self):
"""Constructor"""
pub.subscribe(self.search, "agile.search")
printTreeDocs(extra='L') # this shows the listener
#----------------------------------------------------------------------
def search(self, change):
""""""
print "Hit search"
Main()
proc = Processing()
main = Main()
self.proc = Processing()
--
You received this message because you are subscribed to the Google Groups "pypubsub" group.
To view this discussion on the web visit https://groups.google.com/d/msg/pypubsub/-/9Qpc-0Fui5IJ.
To post to this group, send email to pypu...@googlegroups.com.
To unsubscribe from this group, send email to pypubsub+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pypubsub?hl=en.