title: tkinter open canvas inside Frame
body: <p>I have a canvas which is opening in the main window, but I want it to open in the canvas inside the Frame. I tried to add some crazy (as they're in my hands) attributes, but they didn't solve my problem, so I deleted them and have no idea what to do. Could you help me - how could I realize it?</p>
  
  <p>code:</p>
  
  <pre><code>from tkinter import *
  from tkinter import ttk
  
  
  class Example(Frame): # Frame
   def __init__(self, root):
      Frame.__init__(self, root)
  
      # ---- for grid ----
      canvas_width = 1000  # MUTABLE!!!
      canvas_height = 1000  # MUTABLE!!!
      self.canvas_width = canvas_width
      self.canvas_height = canvas_height
  
      self.warehouse_canvas = Canvas(self, width=canvas_width, height=canvas_height, background="bisque")
      self.x_scrollbar = Scrollbar(self, orient="horizontal", command=self.warehouse_canvas.xview)
      self.y_scrollbar = Scrollbar(self, orient="vertical", command=self.warehouse_canvas.yview)
      self.warehouse_canvas.configure(yscrollcommand=self.y_scrollbar.set, xscrollcommand=self.x_scrollbar.set)
      self.warehouse_canvas.configure(scrollregion=(0, 0, canvas_width, canvas_height)) # c_w c_h изменены
  
      self.x_scrollbar.grid(row=1, column=0, sticky="ew")
      self.y_scrollbar.grid(row=0, column=1, sticky="ns")
      self.warehouse_canvas.grid(row=0, column=0, sticky="nsew")
      self.grid_rowconfigure(0, weight=1)
      self.grid_columnconfigure(0, weight=1)
  
  
      root.columnconfigure(1, weight=1)
      root.rowconfigure(1, weight=1)
  
  
      self.warehouse_canvas.bind("&lt;ButtonPress-1&gt;", self.scroll_start)
      self.warehouse_canvas.bind("&lt;B1-Motion&gt;", self.scroll_move)
  
  
      self.draw_grid(self.warehouse_canvas, canvas_width, canvas_height) # !!!
  
  def draw_grid(root, warehouse_canvas, canvas_width, canvas_height):
      for line in range(0, canvas_width, 10):
          warehouse_canvas.create_line([(line, 0), (line, canvas_height)], fill='#d9d9d9', tags='grid_line_width')
      for line in range(0, canvas_width, 10):
          warehouse_canvas.create_line([(0, line), (canvas_width, line)], fill='#d9d9d9', tags='grid_line_height')
      # warehouse_canvas.grid(row=0, column=0)               color :  #d9d9d9
  
  def scroll_start(self, event):
      self.warehouse_canvas.scan_mark(event.x, event.y)
  
  def scroll_move(self, event):
      self.warehouse_canvas.scan_dragto(event.x, event.y, gain=1)
  
  
  
  if __name__ == "__main__":
     root = Tk()
  
     Example(root).grid(row=0, column=0, # положение
                     columnspan=2, rowspan=2, sticky="nsew")
  
     root.mainloop()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/UEA35.png" rel="nofollow noreferrer">What I have</a></p>
  
  <p><a href="https://i.stack.imgur.com/FKeMF.png" rel="nofollow noreferrer">Where I want it to be</a></p>
  
  <p>Is there any way to do it without rewriting the whole code?</p>