On Fri, Jan 04, 2002 at 03:48:34PM -0500, Craig Hurley wrote: > I have 2 classes that are tk windows, one is a child of the other. > At the top level of the file the parent is made as 'app'. The child > class is spawned from inside the parent class. When the child class is > started several buttons of the parent class need to be DISABLED(better > safe that sorry stuff). The child instance assumes the instance name of > the parent, app. I know this is sloppy. > I need to know how to access the parent instance from the child > instance. > I have tried global and __main__.app and that doesn't work. > > the code looks like: > > class parent: > self.button.config(state=NORMAL) > > def open_child(self): > kid = child() > > class child(parent): > app.button.config(state=DISABLED) > > app = parent() >
You want to be using class constructors here, which have the __init__ magic name. Try something like this: class Parent: def __init__(self): self.button.config(state=NORMAL) def open_child(self): kid = Child(self) # pass in a reference to the Parent instance class Child(Parent): def __init__(self, parent) parent.button.config(state=DISABLED) app = Parent() I hope that that help. I am not sure if that is what you mean. Cheers, Trent -- Trent Mick [EMAIL PROTECTED] _______________________________________________ ActivePython mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/activepython