title: Tkinter: How and best practice to access function outside frame?
body: <p>I am making a small GUI with tkinter, for which the main windows contains several &quot;custom&quot; widgets (frames with several buttons, etc).</p>
  <p>To try and not bloat the <code>__init__()</code> of my main window, I created different classes that inherit from Frame, and in their <code>__init__()</code> I add the different elements such as buttons, etc. A sketch of the architecture is as follows:</p>
  <pre><code>from tkinter import *
  
  class MainWindow(Tk):
      def __init__(self):
          Tk.__init__(self)
          self.upframe= PicFrame(self)
          self.downframe=ButtonFrame(self)
          ...
  
      def manipulate_picframe(self):
          pass
  </code></pre>
  <p>Now in this example <code>PicFrame</code> and <code>ButtonFrame</code> would be two classes that inherit from <code>Frame</code>, and say the first one has a canvas and a label, and the other has two buttons.
  Now my question is, when a button in <code>ButtonFrame</code> is clicked, I would like to (for example) draw a circle on the canvas of <code>PicFrame</code>. Now with the architecture above, the only way I see how to do that is to pass a reference of the function <code>manipulate_picframe()</code> to <code>ButtonFrame</code>, and use that.</p>
  <p>The other way would be of course to not define the classes <code>PicFrame</code> and <code>ButtonFrame</code>, and do everything inside <code>MainWindow</code>, but I feel this would be much less readable.</p>
  <p>What is the best practice in this case? Is there another way besides the two ways I suggested to solve this problem?</p>