Python Tkinter Canvas Many create_window() Items Not Scrolling with Scrollbar
<p>Why doesn't the scrollbar initiate when <code>create_window</code> frame objects start to exceed the bottom <code>self.container</code> window?</p>

<p>My understanding is that widgets are scrollable if they are embedded on the canvas using <code>create_window</code>. For context, I don't want to create a scrolling frame - put all your widget in a frame, use <code>create_window</code> to add that frame to the canvas - because I intend to move these frame objects around on the canvas and leverage a lot of canvas capabilities. According to <a href="http://effbot.org/tkinterbook/canvas.htm#Tkinter.Canvas.create_window-method" rel="nofollow">Effbot</a>, <em>You cannot draw other canvas items on top of a widget.</em>, so if I had a scrolling frame, I wouldn't be able to put widgets on top of that.</p>

<p>So how do I scroll the canvas that contains many <code>create_window</code> objects, or, what am I doing wrong below?</p>

<pre><code>import tkinter as tk

class Canvas_Scrollbar_CreateWindow(tk.Frame):

  def __init__(self, parent):
    tk.Frame.__init__(self, parent)
    self.parent = parent
    self.parent.columnconfigure(0, weight=1)
    self.grid_columnconfigure(0, weight=1)

    self.block_count = 0

    self.button = tk.Button(self, text='Add', command=self.addblock)
    self.button.grid(row=0, column=0, columnspan=2, sticky='new')

    self.container = tk.Frame(self)
    self.container.grid(row=1, column=0, sticky='nsew')

    self.canvas = tk.Canvas(self.container, width=200, height=450)
    self.scrollbar = tk.Scrollbar(self.container,
                                  orient='vertical',command=self.canvas.yview)
    self.canvas.config(yscrollcommand=self.scrollbar.set)
    self.canvas.grid(row=0, column=0, sticky='nsew')
    self.scrollbar.grid(row=0, column=1, sticky='nse')

    self.container.bind('&lt;Configure&gt;', self.handle_scroll)

  def addblock(self):
    self.block = tk.Frame(self.canvas, bd=1, relief='solid')
    self.block.columnconfigure(0, weight=1)
    self.canvas.create_window((0, (self.block_count*25)),
                              window=self.block, anchor="nw",
                              width=200, height=24)
    self.block_count += 1

  def handle_scroll(self, event):
    self.canvas.configure(scrollregion=self.canvas.bbox("all"))

root = tk.Tk()
app = Canvas_Scrollbar_CreateWindow(root)
app.grid(row=0, column=0, sticky='ew')
root.mainloop()
</code></pre>

<p><a href="https://i.stack.imgur.com/csTJE.png" rel="nofollow"><img src="https://i.stack.imgur.com/csTJE.png" alt="tkinter create_window scrollbar"></a></p>

<p>You must re-configure <code>scrollregion</code> when you add items to the canvas.</p>

python tkinter scrollbar tkinter-canvas