title: tkinter: scrollbar autohide without window resize
body: <p>Using the folowing sample code I wrote I am having issues with some behavior.
  I want to add/remove the scrollbar as needed. But when I do it shifts all other elements in the window as the window resizes. This is just a sample to demonstrate the issue, you will see the window resize when the scrollbar is added and removed. In the real application there are more widgets on the window.</p>
  
  <p>Am I trying to do this the right way or if not how can I resolve the issue? I also plan to have a second widget with scrollbars as well in another separate frame.</p>
  
  <pre><code>from tkinter import *
  from tkinter import ttk
  
  class TopFrame(ttk.Frame):
      def __init__(self, parent, col=0, row=0):
          ttk.Frame.__init__(self, parent)
          self.innerframe = ttk.Frame(parent)
  
          self.list_scroll = ttk.Scrollbar(self.innerframe)
          self.list_scroll.grid(column=1, row=0, sticky=NS)
          self.list_scroll.grid_remove()
  
          self.list = Listbox(self.innerframe, width=64, height=8,
                              yscrollcommand=self.list_scroll.set)
          self.list_scroll.config(command=self.list.yview)
          self.list.grid(column=0, row=0, sticky=NSEW)
  
          self.innerframe.grid(column=col, row=row)
  
          self.addbtn = ttk.Button(parent, text='add item',
                                   command=self.additem)
          self.addbtn.grid(column=col, row=row+1, padx=10, pady=2)
          self.delbtn = ttk.Button(parent, text='del item',
                                   command=self.delitem)
          self.delbtn.grid(column=col, row=row+2, padx=10, pady=2)
  
          self.grid_rowconfigure(0, weight=1)
          self.grid_columnconfigure(0, weight=1)
  
      def additem(self):
          count = str(len(self.list.get(0, END)))
          self.list.insert(END, 'demo' + count)
          if len(self.list.get(0, END)) &gt; 8:
              self.list_scroll.grid()
  
      def delitem(self):
          self.list.delete(END)
          if len(self.list.get(0, END)) &lt;= 8:
              self.list_scroll.grid_remove()
  
  class MasterFrame(Tk):
      def __init__(self):
          Tk.__init__(self)
          topframe = TopFrame(self)
  
  if __name__ == '__main__':
      MasterFrame().mainloop()
  </code></pre>