title: Nesting windows/graphs in Tkinter
body: <p>Is there a way to embed a graph produced by an arbitrary plotting function in a Tkinter frame? The function mentioned below plots stuff in a separate window, I want it to plot in the same window, maybe, just nest in the master window. It seems that one might want to use <code>tkinter.Canvas</code> widget if I'm not mistaken, still in my case the graph appears in a separate window. </p>
  
  <pre><code>import tkinter as tk
  
  def plot():
      #stuff for plotting
      #in this case it returns an instance of matplotlib.figure.Figure
  
  class Main(tk.Frame):
      def __init__(self, master):
          tk.Frame.__init__(self, master)
          self.pack()
          self.widgets()
  
      def widgets(self):
          self.menubar = tk.Menu()
          self.plotmenu = tk.Menu(self.menubar)
          self.plotmenu.add_command(label = "Plot", command = lambda: plot())
          self.master.config(menu = self.menubar)
          self.menubar.add_cascade(label = "Plot", menu = self.plotmenu)
          self.canvas = tk.Canvas(self)
          self.canvas.pack()
          self.canvas.create_window(0, 0, window = plot())
  
  root = tk.Tk()
  app = Main(master=root)
  app.mainloop()
  </code></pre>