Suppose I have a tkinter app with the following layout.
I have used an object-oriented hierarchical model such that the classes are instantiated like this:
MainWindow
├── OptionsFrame
│ ├── DataFrame
│ ├── MetaFrame
│ └── SaveFrame
└── PlotFrame
I want to be able to use the plot button within the SaveFrame to run a function which will plot using a FigureCanvasTkAgg canvas object.
I am struggling to see how I can reach the PlotFrame from within the SaveFrame.
So far I have been using a main
parameter in my class declarations, i.e.
class SaveFrame(ttk.Frame):
def __init__(self, main, *args, **kwargs):
super().__init__(main, *args, **kwargs)
self.main = main
which will allow me to go up one level of the hierarchy to the OptionsFrame, but what I need to do is go from
SaveFrame -> OptionsFrame -> MainWindow -> PlotFrame
I don't really know how this is possible.
Thanks
main
attribute for each class (which declares the widget's parent), and you can trace through those to reachMainWindow
. After you get to the parent, you should be able to adjustPlotFrame
, through the instance that is probably declared in there. – Ryanself.master
- so you don't needself.main
. And usingself.master
you can accessparent
and usingself.master.master
can acessgrandparent
- and this can beMainWindow
which has access toPlotFrame
– furas