title: how to scroll the desired columns of treeview in tkinter
body: <p>I am working on a GUI application where to some data will be fetched from the database and will be displayed in a treeview. But the problem is that my treeview has around 20 columns and that is way to much. I mean the whole application can't be fit in my screen.</p>
  <p>So I want to display only 2-3 columns initially and I want the rest of the columns to be visible via scrollbar.</p>
  <p>I have used &quot;displaycolumns&quot; options to display first 3 columns and I have created the scrollbar too but I am unable to figure out that how I can make the rest of columns visible via scrollbar.</p>
  <p>The Following is my code, I have removed buttons method and database functionalities to simplify it</p>
  <pre><code>import tkinter as tk
  from tkinter import ttk
  import openpyxl
  from tkinter import filedialog
  import tkinter.font as tkFont
  
     class MainWindow(tk.Tk):
      def __init__(self,*args,**kwargs):
       tk.Tk.__init__(self,*args,**kwargs)
  
      #Creating Geometry Of the window
      #self.geometry(&quot;500x500+0+0&quot;)
      self.title(&quot;Test Software&quot;)
  
      #Creating Labels
  
      self.agreement_number_label = tk.Label(text=&quot;Agreement Number&quot;)
      self.area_office_label = tk.Label(text=&quot;Area office&quot;)
      self.branch_label = tk.Label(text=&quot;Branch&quot;)
      self.customer_name_label = tk.Label(text=&quot;Customer Name&quot;)
      self.model_label = tk.Label(text=&quot;Model&quot;)
      self.registered_number_label = tk.Label(text=&quot;Registered Number&quot;)
      self.engine_number_label = tk.Label(text=&quot;Engine Number&quot;)
      self.chasis_number_label = tk.Label(text=&quot;Chasis Number&quot;)
      self.make_label = tk.Label(text=&quot;Make&quot;)
  
      #creating entry fields variables
  
      self.agreement_number = tk.StringVar()
      self.area_office = tk.StringVar()
      self.branch = tk.StringVar()
      self.customer_name = tk.StringVar()
      self.model = tk.StringVar()
      self.registered_number = tk.StringVar()
      self.engine_number = tk.StringVar()
      self.chasis_number = tk.StringVar()
      self.make = tk.StringVar()
  
      #creating Entry Fields
  
      self.agreement_number_entry = tk.Entry(textvariable = self.agreement_number)
      self.area_office_entry = tk.Entry(textvariable = self.area_office)
      self.branch_entry = tk.Entry(textvariable = self.branch)
      self.customer_name_entry = tk.Entry(textvariable = self.customer_name)
      self.model_entry = tk.Entry(textvariable = self.model)
      self.registered_number_entry = tk.Entry(textvariable = self.registered_number)
      self.engine_number_entry = tk.Entry(textvariable = self.engine_number)
      self.chasis_number_entry = tk.Entry(textvariable = self.chasis_number)
      self.make_entry = tk.Entry(textvariable = self.make)
  
      #Adding Labels and Entry Fields to the grid
      #1st Row Fields
      self.agreement_number_label.grid(row=0,column=0,pady=(25,0),sticky=&quot;w&quot;,padx=(20,0))
      self.agreement_number_entry.grid(row=0,column=1,pady=(25,0),sticky=&quot;w&quot;)
      self.area_office_label.grid(row=0,column=2,pady=(25,0),sticky=&quot;w&quot;)
      self.area_office_entry.grid(row=0,column=3,pady=(25,0),sticky=&quot;w&quot;)
      self.branch_label.grid(row=0,column=4,pady=(25,0),sticky=&quot;w&quot;)
      self.branch_entry.grid(row=0,column=5,pady=(25,0),sticky=&quot;w&quot;,padx=(0,20))
      #2nd row fields
      self.customer_name_label.grid(row=1,column=0,sticky=&quot;w&quot;,padx=(20,0))
      self.customer_name_entry.grid(row=1,column=1,sticky=&quot;w&quot;)
      self.model_label.grid(row=1,column=2,sticky=&quot;w&quot;)
      self.model_entry.grid(row=1,column=3,sticky=&quot;w&quot;)
      self.registered_number_label.grid(row=1,column=4,sticky=&quot;w&quot;)
      self.registered_number_entry.grid(row=1,column=5,sticky=&quot;w&quot;,padx=(0,20))
      #3rd Row Fields
      self.chasis_number_label.grid(row=2,column=0,sticky=&quot;w&quot;,padx=(20,0))
      self.chasis_number_entry.grid(row=2,column=1,sticky=&quot;w&quot;)
      self.engine_number_label.grid(row=2,column=2,sticky=&quot;w&quot;)
      self.engine_number_entry.grid(row=2,column=3,sticky=&quot;w&quot;)
      self.make_label.grid(row=2,column=4,sticky=&quot;w&quot;)
      self.make_entry.grid(row=2,column=5,sticky=&quot;w&quot;,padx=(0,20))
  
      #Creating a search button
      self.search_button = tk.Button(text = &quot;Search Record&quot;,width=25)
  
      #Adding the Search Button into the grid
      self.search_button.grid(row=3,column=0,columnspan=6,pady=10)
  
      #Adding a Seperator to the grid
      ttk.Separator(orient=&quot;horizontal&quot;).grid(row=4,columnspan=6,sticky=&quot;ew&quot;)
  
  
      #Creating A Treeview
      self.treeview = ttk.Treeview(height=6)
      self.treeview['columns'] = (&quot;One&quot;,&quot;Two&quot;,&quot;Three&quot;)
      self.treeview.column('#0',width=100)
      self.treeview.heading(&quot;#0&quot;, text=&quot;Testing&quot;)
      self.treeview.heading(&quot;One&quot;, text=&quot;Column A&quot;)
      self.treeview.heading(&quot;Two&quot;, text=&quot;Column B&quot;)
      self.treeview.heading(&quot;Three&quot;, text=&quot;Column C&quot;)
      self.treeview.grid(row=5,rowspan=5,column=0,columnspan=4,pady=(10,0))
  
      #Adding Default Data to The Treeview
      for i in range(10):
          self.treeview.insert(&quot;&quot; , &quot;end&quot;,    text=&quot;Line &quot;+str(i), values=(&quot;1A&quot;,&quot;1b&quot;))
  
      #Creating a treeview scrollbar
      self.vertical_scrollbar = tk.Scrollbar(orient='vertical')
      self.horizontal_scrollbar = tk.Scrollbar(orient='horizontal')
  
      #adding scrollbars to the grid
      self.vertical_scrollbar.grid(row=5,column=4,rowspan=6)
      self.horizontal_scrollbar.grid(row=10,column=0,columnspan=4)
  
      #configuring scrolls to treeview
      self.horizontal_scrollbar.configure(command=self.treeview.xview)
      self.vertical_scrollbar.configure(command=self.treeview.yview)
  
      #configuring treeview to Scrollbar
      self.treeview.configure(yscrollcommand=self.vertical_scrollbar.set)
      self.treeview.configure(xscrollcommand=self.horizontal_scrollbar.set)
  
      #Creating buttons
      self.view_all_record_btn = tk.Button(text=&quot;View All Records&quot;,width=15)
      self.add_record_btn = tk.Button(text=&quot;Add Record&quot;,width=15)
      self.edit_record_btn = tk.Button(text=&quot;Edit Record&quot;,width=15)
      self.delete_record_btn = tk.Button(text=&quot;Delete Record&quot;,width=15)
      self.upload_file_btn = tk.Button(text=&quot;Upload File&quot;,width=15)
  
      #Adding Buttons to the Grid
      self.view_all_record_btn.grid(row=5,column=5,pady=(10,0))
      self.add_record_btn.grid(row=6,column=5)
      self.edit_record_btn.grid(row=7,column=5)
      self.delete_record_btn.grid(row=8,column=5)
      self.upload_file_btn.grid(row=9,column=5,pady=(0,20))
  
      root = MainWindow()
      root.mainloop()
  </code></pre>
  <p>My problem is that I have to add around 20 columns here but I only want to display 3-4 columns at a time rest columns will only be visible via scrollbar, my scrollbar for rows works fine but I can't figure out how to do that for columns</p>