title: Double Scrollbars in Tkinter Python
body: <p>I cannot get x and y scrollbars to work in Tkinter with Python, although I have followed multiple examples:</p>
  <ol>
  <li><a href="https://stackoverflow.com/questions/31533623/how-to-add-2-scrollbars-with-tkinter-in-python-3-4">How to add 2 scrollbars with tkinter in python 3.4</a></li>
  <li><a href="https://stackoverflow.com/questions/3085696/adding-a-scrollbar-to-a-group-of-widgets-in-tkinter">Adding a scrollbar to a group of widgets in tkinter</a></li>
  <li><a href="https://lucasg.github.io/2015/07/21/How-to-make-a-proper-double-scrollbar-frame-in-Tkinter/" rel="nofollow noreferrer">How to make a proper double scrollbar frame in tkinter</a></li>
  <li><a href="https://stackoverflow.com/questions/9561030/vertical-and-horizontal-scrollbars-on-tkinter-widget">Vertical and Horizontal Scrollbars on Tkinter Widget</a></li>
  <li><a href="https://riptutorial.com/tkinter/example/27784/scrolling-a-canvas-widget-horizontally-and-vertically" rel="nofollow noreferrer">Scrolling a Canvas widget horizontally and vertically</a></li>
  </ol>
  <p>The scrollbars appear, but do not activate when the window is smaller than the frame. How can I get this to work (see image below)?</p>
  <p><a href="https://i.stack.imgur.com/tM5Zv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tM5Zv.png" alt="Problem 1" /></a></p>
  <p>Below is the minimal code that is producing my problem (Python 3.7)</p>
  <pre><code>import tkinter as tk
  from tkinter import ttk
  
  big_font = (&quot;Arial&quot;, 50)
  
  class DoubleScrollbarFrame(ttk.Frame):
  
      def __init__(self,
                   parent,
                   *args,
                   **kwargs):
          self.parent = parent
  
          super().__init__(self.parent,
                           *args,
                           **kwargs)
  
          #Set widgets to fill main window such that they are
          #all the same size
          self.columnconfigure(0, weight=1)
          self.rowconfigure(0, weight=1)
  
          self.create_widgets()
          self.position_widgets()
  
      def create_widgets(self):
          self.canvas = tk.Canvas(self)
          self.frame = ttk.Frame(self.canvas)
          self.scroll_x = ttk.Scrollbar(self,
                                        orient = tk.HORIZONTAL,
                                        command = self.canvas.xview)
          self.scroll_y = ttk.Scrollbar(self,
                                        orient = tk.VERTICAL,
                                        command = self.canvas.yview)
          self.canvas.config(xscrollcommand = self.scroll_x.set,
                             yscrollcommand = self.scroll_y.set)
          self.canvas.create_window((0,0),
                                    window = self.frame,
                                    anchor = 'nw')
          self.frame.bind('&lt;Configure&gt;',
                          self.set_scrollregion)
          self.sizegrip = ttk.Sizegrip(self)
  
          #Test
          self.test1 = tk.Label(self.frame,
                                text = 'Test 1',
                                font = big_font)
          self.test2 = tk.Label(self.frame,
                                text = 'Test 2',
                                font = big_font)
          self.test3 = tk.Label(self.frame,
                                text = 'Test 3',
                                font = big_font)
  
      def position_widgets(self,
                           **kwargs):
          self.test1.grid(row = 0,
                          column = 0,
                          sticky = 'w')
          self.test2.grid(row = 1,
                          column = 0,
                          sticky = 'w')
          self.test3.grid(row = 2,
                          column = 0,
                          sticky = 'w')
          
          self.scroll_x.grid(row = 1,
                             column = 0,
                             sticky = 'ew')
  
          self.scroll_y.grid(row = 0,
                             column = 1,
                             sticky = 'ns')
  
          self.canvas.grid(row = 0,
                           column = 0,
                           sticky = 'nsew')
          
          self.frame.grid(row = 0,
                          column = 0,
                          sticky = 'nsew')
  
          self.sizegrip.grid(row = 1,
                             column = 1,
                             sticky = 'se')
  
      def set_scrollregion(self,
                           event):
          print('Frame Dimensions: {} x {}'.format(self.frame.winfo_width(),
                                                   self.frame.winfo_height()))
          print('Canvas Dimensions: {} x {}'.format(self.canvas.winfo_width(),
                                                    self.canvas.winfo_height()))
          self.canvas.configure(scrollregion = self.canvas.bbox('all'))
  
  class MainApp(tk.Tk):
  
      def __init__(self,
                   *args,
                   **kwargs):
  
          super().__init__(*args,
                           **kwargs)
  
          #Set widgets to fill main window such that they are
          #all the same size
          self.columnconfigure(0, weight=1)
          self.rowconfigure(0, weight=1)
  
          self.create_widgets()
          self.position_widgets()
  
      def create_widgets(self):
          self.frame = DoubleScrollbarFrame(self)
  
      def position_widgets(self):
          self.frame.grid(row = 0,
                          column = 0,
                          sticky = 'nsew')
  
      def exit(self):
          self.destroy()
  
  if __name__ == '__main__':
  
      #Create GUI
      root = MainApp()
  
      #Run program
      root.mainloop()
  </code></pre>