don't understand namespaces...

Mike Driscoll kyosohma at
Thu Apr 30 16:37:15 CEST 2009

On Apr 30, 9:11 am, Lawrence Hanser <lhan... at> wrote:
> Dear Pythoners,
> I think I do not yet have a good understanding of namespaces.  Here is
> what I have in broad outline form:
> ------------------------------------
> import Tkinter
> Class App(Frame)
>       define two frames, buttons in one and Listbox in the other
> Class App2(Frame)
>       define one frame with a Text widget in it
> root = Tk()
> app = App(root)
> win2 = Toplevel(root)
> app2 = App2(win2)
> root.mainloop()
> ------------------------------------
> My understanding of the above goes like this:
> 1) create a root window
> 2) instantiate a class that defines a Frame in the root window
> 3) create another Toplevel window
> 4) instantiate another class that defines a frame in the Toplevel window (win2)
> What I cannot figure out is how to reference a widget in app2 from app...
> I hope this is sort of clear.
> Any assistance appreciated.
> Thanks,
> Larry

It depends on how you're doing this. If the first frame opens the 2nd
frame, then you can have a handle to the 2nd in the 1st. Something
like this:

self.newFrame = NewFrame()

Then you can get at the attributes of the 2nd frame:


If you're opening both at the same time, you'll have to come up with
something else, like Queues or pubsub.

- Mike

More information about the Python-list mailing list