title: How do you size a tkinter frame dynamically
body: <p>I have a frame I want to use as a sidebar navigation menu. I want the menu to be resize-able with the mouse. I have code that sizes the frame but it doesn't resize until you resize the toplevel window. I know about PanedWindows and that will not work for me.  </p>
  
  <pre><code>from tkinter import *
  
  
  def dragbar_on_click(event):
      event.widget.mouse_x = event.x
  
  
  def dragbar_on_release(event):
      event.widget.mouse_x = 0
  
  
  def dragbar_on_motion(event):
      if event.widget.mouse_x != 0:
          width = event.widget.parent.winfo_width() + event.x - event.widget.mouse_x
  
          event.widget.parent.config(width=width)
  
  
  class DragBar(Frame):
      def __init__(self, parent, *args, **kwargs):
          super().__init__(parent, *args, **kwargs)
          self.parent = parent
  
  
  class SideMenu(Frame):
      def __init__(self, parent, *args, **kwargs):
          super().__init__(parent, *args, **kwargs)
  
          self.config(bg='red', width=300)
          self.rowconfigure(0, weight=1)
          self.grid(sticky='NSEW')
          self.grid_propagate(0)
  
          self.frame = Frame(self, bg='purple')
          self.columnconfigure(0, weight=1)
          self.frame.grid(row=0, column=0, sticky='NSEW')
  
          self.dragbar = DragBar(self, bg='green', width=10)
          self.dragbar.mouse_x = 0
          self.dragbar.grid(row=0, column=1, sticky='NSW')
  
          self.dragbar.bind("&lt;Motion&gt;", dragbar_on_motion)
          self.dragbar.bind("&lt;Button-1&gt;", dragbar_on_click)
          self.dragbar.bind("&lt;ButtonRelease-1&gt;", dragbar_on_release)
  
  
  root = Tk()
  root.rowconfigure(0, weight=1)
  root.columnconfigure(1, weight=1)
  
  f = SideMenu(root)
  Label(f.frame, text='This is a test line.').grid(sticky='NW')
  
  root.mainloop()
  </code></pre>