Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tkinter access child from parent

I have a master canvas

canvas = Canvas(root,width=1200,height=800)

and a lot of child widgets such as lists and frames and canvases inside frames

I want to write a function that gives in just the parent canvas and access the child in a form like

def showInstrumentList(canvas):
    child_listbox = canvas.listbox <== this kind of approach (not real code)

I have a lot of child widgets spread across my program and i really need a way to access these child widgets from the top down. (So everything starting from the parent and finding its way down)

Is there anyway to do that?

like image 318
user3467433 Avatar asked May 26 '26 22:05

user3467433


1 Answers

You can do

canvas = Canvas(root,width=1200,height=800)
canvas.label = Label(canvas)

You can add new attributes.

like image 76
User Avatar answered Jun 01 '26 19:06

User