Kent Johnson wrote: > William Gill wrote: > >> I am trying to get & set the properties of a widget's parent widget. >> What I have works, but seems like a long way around the block. First >> I get the widget name using w.winfo_parent(), then i convert the name >> to a reference using nametowidget(). >> >> self.nametowidget(event.widget.winfo_parent()).hasChanged= True > > > Personally I think it is bad design for a widget to assume anything > about its enclosing environment. What about passing a StringVar or > IntVar to the child widget and letting it work with that? > > Kent
Maybe I should clarify what I am doing and why, so that I can get a better understanding of your replies. The overall app is a gui editor for a database made up of several related tables; one for basic info, one for their various phone numbers (publish, contact, fax,cell, etc), one for various addresses (publish ,ship to, mail to, etc.), one for the services they subscribe to, etc. The editor brings records from each of the various tables together in one “record” for editing. Each table has an associated python/tkinter class (widget) that displays the fields in a parent widget, and each field is a child of the table widget. So “city” is a child of address, is a child of client. If I change or add a phone number that db table will need updating when I’m done, but the address table may not. I have designed each table class with a hasChanged attribute, initialized to False, if a child Entry widget changes I set has changed to True. When I’m done the exit routine runs each table objects save routine, which checks hasChanged to see if an update query needs to be run on that table. Client - basicData object (data from client table) - company - contact person - notes - phones object (data from phonenumber table) - type (cell, fax, publish, etc) - areaCode - exchange - base If I change the area code in one record only the phonenumber table needs to be updated, but since areaCode is a child of phones, phones.hasChanged needs to be set to True by the areaCode entry widget. > Personally I think it is bad design for a widget to assume anything > about its enclosing environment. What about passing a StringVar or > IntVar to the child widget and letting it work with that? This is not a criticism, but how is passing a known intVar or stringVar any different than designing with the knowledge that an areaCode widget can not exist except as a child of phonenumber? Besides, I need to pass the state of areaCode (has it changed or not), not its value? Bill -- http://mail.python.org/mailman/listinfo/python-list