pubsub necessary in this case?

Sorry took two days to get back to this: I was afraid to try your
sample app and thus reboot the universe, but then I figured, hey, what
have I got to lose? :smiley:

As it turns out, the problem, dumb as it is, was the difference between:

.GetParent()
"Returns the parent window of this window, or None if there isn't one."

and

.GetTopLevelParent()
"Returns the first frame or dialog in this window's parental hierarchy."

My problem was misunderstanding (unless I misunderstand my
misunderstanding!) the word "top" here; I thought it meant the
furthest-back "ancestor" parent, not the closest parent. I guess the
metaphor is a stack of pancakes, with the *top* level parent being the
closest parent, not the most distant (grand)parent.

And so your way would have worked just fine for me. Well, at least
along the way I learned how to use wx.lib.pubsub a bit, and it will no
doubt be useful for me later on and is probably better practice as
Jorgen said. Thanks to you both, Jorgen and Peter.

···

On Thu, Apr 10, 2008 at 5:50 AM, Peter Damoc <pdamoc@gmail.com> wrote:

I don't know how to solve your problem but could you elaborate a little bit
more because I simply cannot understand couldn't you simply use the first
frame as the parent of the second frame and get it via second frame's
GetParent()

something like this:

import wx
class Second(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, parent, title="I am Second")
        self.button = wx.Button(self, label="Please push me! Me! Me! Me!")
         self.button.Bind(wx.EVT_BUTTON, self.Nirvana)
    def Nirvana(self, evt):
        self.GetParent().text.SetValue("Nirvana Reached! Please reboot The
Universe!")

class First(wx.Frame):
    def __init__(self):
         wx.Frame.__init__(self, None, title="I am First")
        self.text = wx.TextCtrl(self)

app = wx.App(0)
first = First()
first.Show()
second = Second(first)
second.Show()
second.CenterOnScreen()
app.MainLoop()