Problem with wx.lib.pubsub

Steve Senior wrote:

Previously I was calling the model.SecondOne() function like this:

    def SetUserPrefs(self):
        model.SecondOne("BUTTONPANEL_BORDER_COLOR")

and this didn't work.

Then when I changed it to this:
    def __init__(self):
        wx.Frame.__init__(self, None, -1, "MyApp",

        # Get and set the users preferences from the database
        model.SecondOne("BUTTONPANEL_BORDER_COLOR")

i.e. I pulled it out of the SetUserPrefs method, the message was received and processed!

Why can't I do it the original way from within the SetUserPrefs method?

What namespace is "model" in? Maybe you don't have access to it in the SetUserPrefs() method -- should it be self.model? wx.GetApp().model?

Have you got your app set up so that you see the standard error messages? If there is an error in a callback, wxPython won't stop, but it will print an error, so you want to make sure you can see those when testing.

Again -- make a small, self-contained sample, and we can really tell you what's going on (or, quite likely, you'll figure it out yourself when you isolate the code).

-Chris

···

--
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

Chris.Barker@noaa.gov

Again -- make a small, self-contained sample, and we can really tell you
what's going on (or, quite likely, you'll figure it out yourself when
you isolate the code).

-Chris

OK I'll make a self-contained sample over the weekend and post here if I don't
work it out myself.

I'm pretty sure that I know it is because you need to call the model function
that broadcasts the message via a method that is bound to an event.

But I'm not sure why this has to be the case.

Thanks,
Steve.

Steve Senior <stevensenior <at> f2s.com> writes:

I've solved this now.

Let's just put it down to a PBKAC!

(Problem Between Keyboard and Chair)

Thanks for the replies,
Steve.