tags:

views:

15

answers:

1

Hi all, I am little confused about how to get the top frame in an application. I start off my application with the usual

class AppFrame(ClientGUI.MyFrame): #ClientGUI.MyFrame generated by wxformbuilder. 
def __init__(self):
    # create some panels. 
    # Create some object classes that invoke objects of other classes.
    # .. do other stuff ... 

if __name__ == '__main__':
    app = wx.App(0)
    frame = AppFrame()
    frame.Show()
    app.MainLoop()

Given that I have a deeply nested class-invocation sequence, I would like one of my objects in the bottom of the invocation hierarchy to access some panel in the application (basically put some gui stuff into that panel). One way I could think of is to include the application object ('self') as parameter into my object invocation sequence so that the last object has access to the application object. But this seems rather convoluted given that all the intermediate objects don't need access to the application.

Is there a clean way to access the application object? Also, what exactly do I want to access -- the "frame" object or the "app" object ? I'm not sure of the difference between these two objects.

A: 

I don't usually recommend doing it that way, but the method you want is probably:

topFrame = wx.GetTopLevelParent()

If you need inter-class communication, I usually use PubSub. Anyway, I hope that helps!

Mike Driscoll
Thanks for the comment. Let me try it out and will get back on this. regards.
G.A.
It works ! :-) .
G.A.