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?

有帮助吗?

解决方案

You can do

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

You can add new attributes.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top