title: Tkinter, functions over other classes
body: <p>I'm trying to understand more about classes. I want to play around with this example <a href="https://stackoverflow.com/questions/17466561/best-way-to-structure-a-tkinter-application">Best way to structure a tkinter application?</a> from Bryan Oakley. But now I have a problem, I want to make a simple <code>destroy</code> function (here in the <code>Toolbar</code>, but get only errors. Or do I need to make all functions in the <code>Mainwindow</code>?</p>
  <pre><code>import tkinter as tk
  from tkinter import ttk
  
  
  class MainWindow(tk.Tk):
      def __init__(self, bg=&quot;#1f2327&quot;, fg=&quot;#c4ddf4&quot;, *args, **kwargs):
          tk.Tk.__init__(self,  *args, **kwargs)
          self.geometry(&quot;1300x850&quot;)                                       # Window Options
  
          self.bg = bg
          self.fg = fg
  
          self.toolframe = Toolbar(bg=self.bg)                            # import classes and initialize
          self.navbar = Navbar(self)
  
          self.toolframe.toolframe.pack(ipady=5, fill=&quot;x&quot;)                # place the widgets from TOOL BAR
          self.navbar.navbar.pack(side=&quot;left&quot;, ipadx=40, fill=&quot;y&quot;)
  
  
  class Toolbar(tk.Frame):                                                # toolbar class
      def __init__(self, bg=None, fg=&quot;#c4ddf4&quot;, hoverdark=&quot;#2b3036&quot;,
                   *args, **kwargs):
          tk.Frame.__init__(self,  *args, **kwargs)
  
          self.bg = bg
          self.fg = fg
          self.hoverdark = hoverdark
  
          self.toolframe = tk.Frame(bg=self.bg)                           # tool frame
  
          self.exitstyle = ttk.Style()                                    # set style for the exit button
          self.exitstyle.theme_use(&quot;clam&quot;)
          self.exitstyle.configure('EXIT.TButton', background=self.bg, foreground=self.fg, borderwidth=0,
                                   focuscolor=&quot;none&quot;, font=(&quot;Bahnschrift&quot;, 10), width=5)
          self.exitstyle.map('EXIT.TButton',
                             background=[(&quot;pressed&quot;, &quot;red&quot;), (&quot;active&quot;, &quot;#ff5353&quot;)]
                             )
  
          self.exitbutton = ttk.Button(self.toolframe,                    # exit button
                                       text=&quot;\u26CC&quot;,
                                       style='EXIT.TButton',
                                       command=self.closeApp  #&lt;------------------------------HERE
                                       )
  
          self.toolstyle = ttk.Style()                                    # set style for min and max button
          self.toolstyle.theme_use(&quot;clam&quot;)
          self.toolstyle.configure('TOOL.TButton', background=self.bg, foreground=self.fg, borderwidth=0,
                                   focuscolor=&quot;none&quot;, font=(&quot;Bahnschrift&quot;, 10), width=5)
          self.toolstyle.map('TOOL.TButton',
                             background=[(&quot;pressed&quot;, &quot;red&quot;), (&quot;active&quot;, self.hoverdark)]
                             )
  
          self.maximizebutton = ttk.Button(self.toolframe,                # maximize button
                                           text=&quot;\u2610&quot;,
                                           style=&quot;TOOL.TButton&quot;
                                           )
  
          self.minimizebutton = ttk.Button(self.toolframe,                # minimize button
                                           text=&quot;\u268A&quot;,
                                           style=&quot;TOOL.TButton&quot;)
  
          self.exitbutton.pack(side=&quot;right&quot;, fill=&quot;y&quot;)                        # exit button pack
          self.maximizebutton.pack(side=&quot;right&quot;, fill=&quot;y&quot;)                    # maximize button pack
          self.minimizebutton.pack(side=&quot;right&quot;, fill=&quot;y&quot;)                    # minimize button pack
  
      def closeApp(self):             #&lt;-----------------------------------------------HERE
          MainWindow.destroy(self)
  
  
  class Navbar(tk.Frame):                                                        # navbar class
      def __init__(self, *args, **kwargs):
          tk.Frame.__init__(self, *args, **kwargs)
          self.navbar = tk.Frame(bg=&quot;black&quot;)
  
  
  if __name__ == &quot;__main__&quot;:
      MainWindow()
      tk.mainloop()
  </code></pre>