faqts : Computers : Programming : Languages : Python : Tkinter

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

12 of 16 people (75%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

From within a function, is there a way to determine what the parent of a calling widget is?

Aug 22nd, 2000 00:49
unknown unknown, Mark Tipton, Richard Chamberlain


from Tkinter import *
root=Tk()
frame=Frame(root)
button=Button(frame,text='Click Me')
button.pack()
frame.pack(fill=BOTH,expand=1)
def clicker(event):
    event.widget.master.configure(bg='blue')
button.bind('<Button>',clicker)
root.mainloop()
If you bind an event you have access to the calling widget via 
event.widget, so you have access to the calling widget's parent via 
event.widget.master.