title: How to add 2 scrollbars with tkinter in python 3.4?
body: <p>I have the following code:</p>
  
  <pre><code>from win32com.client import Dispatch
  from tkinter import *
  from tkinter import ttk
  import tkinter
  
  class applicazione:
  
  def __init__(self, root):
      self.root = root
      self.root.title('Controllo dati per fatturazione elettronica - Manticle - Smith &amp; Nephew Italia')
      ttk.Frame(self.root, width=300, height=250).pack()
  
  
  
  
  
  
      #### label list
      self.titoli = list()
      self.titoli_BFT = ["Num_Doc", "Cod_Art", "Unita Misura", "Tot_Prod", "Quant_Prod", "Perc_IVA_Prod", "Tot_IVA_Prod",
                         "Linea_Prod", "Sconto", "Perc_Sconto", "Tipo_Sconto", "Cod_Art2", "Desc_Art"]
      self.titoli_HFT = ["Dest_Cod_FIS_P_Iva", "Cod_Cli", "Dest_RagSoc1", "Dest_RagSoc2",
                         "Dest_Indirizzo", "Dest_CAP", "Dest_Localita", "Dest_Provincia", "Cli_Cod_Fis_P_Iva",
                          "Cod_Dest", "Cli_RagSoc1", "Cli_RagSoc2", "Cli_Indirizzo", "Cli_CAP",
                         "Cli_Localita", "Cli_Provincia", "Tipo_Doc", "pre_Num_Doc", "Num_Doc",
                          "Data_Doc", "Vs_Rif", "Data_Rif", "Blank", "Blank2", "CPT", "Scad_Pagamento",
                         "Descr", "Num_Ord", "Tot_Imp", "Tot_IVA", "Tot_Doc", "Nazione", "IPA", "Reg_Fiscale"]
  
      self.titoli_IVA = ["Num_Doc_TMP", "Num_Doc", "Imponibile", "IVA, Tot", "Perc_IVA"]
  
      self.titoli_RIF_DOC = [ "Num_Doc_TMP", "Num_Doc", "Rif_Doc" ]
  
      self.titoli_RIF_DOC_BFT = ["Num_Doc_TMP", "Num_Doc", "Cod_Art", "NOTE" ]
  
      self.titoli_anomalieBFT = ["ordine", "anomalia"]
  
      self.titoli_anomalieHFT = ["ordine", "anomalia"]
  
      self.inizializza_widgets()
      self.lettura()
  
  
  
  def inizializza_widgets(self):
      #label 
  
      self.lblins=tkinter.Label(self.root, text="Controllo dati per fatturazione elettronica", font=("Helvetica", 12))
      self.lblins.place(x=10, y=10
  
  
  
      for i in range (0,len(self.titoli_HFT)):
          j = 80*i
          self.lblnome=tkinter.Label(self.root, text= self.titoli_HFT[i], font=("Helvetica", 8))
          self.lblnome.place(x=85+j, y=50)
  
  
      #buttons
  
      ttk.Button(self.root, , text='Inserisci', width='10').place(x=645, y=590)
      #pulsante lettura
      ttk.Button(self.root, text='Modifica', width='10').place(x=725, y=590)
  
      ttk.Button(self.root, text='Indietro', width='10').place(x=805, y=590)
  
      ttk.Button(self.root, text='Avanti', width='10').place(x=885, y=590)
  
  
  def onFrameConfigure(self, event):
      '''Reset the scroll region to encompass the inner frame'''
      self.canvas.configure(scrollregion=self.canvas.bbox("all"))
  
  def lettura(self):
          xl= Dispatch("Excel.Application")
          xl.Visible = True
  
  
          self.checkb_intvar = list()   #contiene una lista di 1 o 0 associati alle checkbox nella lista quadratini
          self.quadratiniB = l = [None] * (13 * len(self.titoli_BFT) )
          self.quadratiniH = l = [None] * (13 * len(self.titoli_HFT) )
  
  
          wbH = xl.Workbooks.Open(r'C:\Users\\Marco\\LAVORO\\Smith&amp;Nephew\\appRonca\\fonte\\HFT_SAP_2.csv')
          print("wbH")
  
          wsH=wbH.WorkSheets(1) # get a reference to the first sheet
  
  
          cont = 0
  
          MAX = 3  #13 lunghezza visibile senza barra navigatrice del numero di righe nella finestra 13
          cont = 0
          for i in range(0, MAX):
              for j in range(0,len(self.titoli_HFT)):
                  print("for for")
                  cont = cont + 1
                  print("i")
                  print(i)
                  print("j")
                  print(j)
  
                  print(" The {} set is often represented as {{0}} ".format("empty"))
  
  
                  #### indexes for DI excel cells management
                  k = 80*j      #i con j
                  l = 40*i      #k con l
  
  
                  contvalueX = i + 1  #con zero da errore allora +1
                  contvalueY = j + 1  #con zero da errore allora +1
  
                  self.txt1 = tkinter.Text(self.root, width='10', height='1')
  
  
                  #Reading excel cells file
  
                  if (wsH.Cells(contvalueX, contvalueY ).Value != None):
  
                      self.txt1.insert('1.0', wsH.Cells(contvalueX, contvalueY ).Value)#ws.Cells(1,i).Value
                      self.txt1.tag_add("start", "1.0", "1.13")
                      if (contvalueY == 1 ):  
                          self.txt1.tag_config("start", background="white", foreground="red")
                      #self.txt1.tag_configure("red", foreground="red")
                      #self.txt1.highlight_pattern("word", "red")
                      #self.txt1 = tkinter.Text(self.root, width='10', height='1', text = ws.Cells(1,i).Value)
                      self.txt1.place(x=85+k, y=80+l)  #5 + 80
                      print("if")
  
                  else:  #None case
                      print("else")
                      self.txt1.insert('1.0', "")
                      self.txt1.place(x=85+k, y=80+l)
                      if (contvalueY == 1 ):  
                          self.txt1.tag_config("start", background="white", foreground="red")
  
  
  
  
          wbH.Close()
          xl.Quit()
  
  
  if __name__ == '__main__':
      root = tkinter.Tk()
      w, h = root.winfo_screenwidth(), root.winfo_screenheight()
      root.geometry("%dx%d+0+0" % (w, h))
      applicazione(root)
      root.mainloop()
  </code></pre>
  
  <p>The application runned:</p>
  
  <p><img src="https://i.stack.imgur.com/zvdQK.png" alt="application image without scrollbar"></p>
  
  <p>I read data from an excel file (lettura function)
  but i would like to add an horizontal and a vertical scrollbar i read first of all this: </p>
  
  <p><a href="https://stackoverflow.com/questions/3085696/adding-a-scrollbar-to-a-grid-of-widgets-in-tkinter">Adding a scrollbar to a group of widgets in Tkinter</a></p>
  
  <p>but use "grid" that i do not use and i'm not able to associate my double "for" "Text" to the vertical scroll bar  (Lettura function)</p>
  
  <p>The following code is edited with the scrollbar but does not work:</p>
  
  <pre><code>import tkinter as tk
  
  from win32com.client import Dispatch
  from tkinter import *
  #from tkinter import ttk
  import tkinter
  
  class Example(tk.Frame):
      def __init__(self, root):
  
          tk.Frame.__init__(self, root)
          root.title('Controllo dati per fatturazione elettronica - Manticle - Smith &amp; Nephew Italia')
          #tk.Frame(root, width=100, height=450).pack()
  
  
  
          self.canvas = tk.Canvas(root,  borderwidth=0, background="#C0C0C0")
          self.frame = tk.Frame(self.canvas, background="#ffffff")
          self.vsb = tk.Scrollbar(root, orient="vertical", command=self.canvas.yview)
          self.canvas.configure(yscrollcommand=self.vsb.set)
  
          self.vsb.pack(side="right", fill="y")
          self.canvas.pack(side="left", fill="both", expand=True)
          self.canvas.create_window((4,4), window=self.frame, anchor="nw", 
                                    tags="self.frame")
  
          self.frame.bind("&lt;Configure&gt;", self.onFrameConfigure)
  
  
          self.titoli_BFT = ["Num_Doc", "Cod_Art", "Unita Misura", "Tot_Prod", "Quant_Prod", "Perc_IVA_Prod", "Tot_IVA_Prod",
                             "Linea_Prod", "Sconto", "Perc_Sconto", "Tipo_Sconto", "Cod_Art2", "Desc_Art"]
  
          self.titoli_HFT = ["Dest_Cod_FIS_P_Iva", "Cod_Cli", "Dest_RagSoc1", "Dest_RagSoc2",
                             "Dest_Indirizzo", "Dest_CAP", "Dest_Localita", "Dest_Provincia", "Cli_Cod_Fis_P_Iva",
                              "Cod_Dest", "Cli_RagSoc1", "Cli_RagSoc2", "Cli_Indirizzo", "Cli_CAP",
                             "Cli_Localita", "Cli_Provincia", "Tipo_Doc", "pre_Num_Doc", "Num_Doc",
                              "Data_Doc", "Vs_Rif", "Data_Rif", "Blank", "Blank2", "CPT", "Scad_Pagamento",
                             "Descr", "Num_Ord", "Tot_Imp", "Tot_IVA", "Tot_Doc", "Nazione", "IPA", "Reg_Fiscale"]
  
  
          #self.inizializza_widgets()
          self.populate()
          self.lettura()
  
  
  
  
      def inizializza_widgets(self):
          #label title
  
          self.lblins=tk.Label(root, text="Controllo dati per fatturazione elettronica", font=("Helvetica", 12))
          self.lblins.place(x=10, y=10)
  
  
  
          for i in range (0,len(self.titoli_HFT)):
              j = 80*i
              self.lblnome=tk.Label(root, text= self.titoli_HFT[i], font=("Helvetica", 8))
              self.lblnome.place(x=85+j, y=50)
  
  
          #965 560
          tk.Button(root, text='Inserisci', width='10').place(x=645, y=590)
          #pulsante lettura
          tk.Button(root, text='Modifica', width='10').place(x=725, y=590)
  
          tk.Button(root, text='Indietro', width='10').place(x=805, y=590)
  
          tk.Button(root, text='Avanti', width='10').place(x=885, y=590)
  
  
      def lettura(self):
              xl= Dispatch("Excel.Application")
              xl.Visible = True
  
              wbH = xl.Workbooks.Open(r'C:\Users\\Marco\\LAVORO\\Smith&amp;Nephew\\appRonca\\fonte\\HFT_SAP_2.csv')
              print("wbH")
  
              wsH=wbH.WorkSheets(1) # get a reference to the first sheet
  
  
  
              cont = 0
  
              MAX = 9  #13 lunghezza visibile senza barra navigatrice del numero di righe nella finestra 13
              cont = 0
  
  
  
  
  
  
  
              for i in range(0, MAX):
                  for j in range(0,len(self.titoli_HFT)):
                      print("for for")
                      cont = cont + 1
  
                      print("cont")
                      print(cont)
  
                      #### INDEXES
                      k = 80*j      #i con j
                      l = 40*i      #k con l
  
  
                      contvalueX = i + 1  #con zero da errore allora +1
                      contvalueY = j + 1  #con zero da errore allora +1
  
                      self.txt1 = tk.Text(root, width='10', height='1')
  
  
  
  
                      #Lettura celle del file HFT
  
                      if (wsH.Cells(contvalueX, contvalueY ).Value != None):
  
                          self.txt1.insert('1.0', wsH.Cells(contvalueX, contvalueY ).Value)#ws.Cells(1,i).Value
                          self.txt1.tag_add("start", "1.0", "1.13")
                          if (contvalueY == 1 ):  
                              self.txt1.tag_config("start", background="white", foreground="red")
  
                          self.txt1.place(x=85+k, y=80+l)  #5 + 80
                          print("if")
  
                      else: #None case
                          print("else")
                          self.txt1.insert('1.0', "")
                          self.txt1.place(x=85+k, y=80+l)
                          if (contvalueY == 1 ):  #### qui si richiama la funziona regole con tutte le regole
                              self.txt1.tag_config("start", background="white", foreground="red")
  
              wbH.Close()
              xl.Quit()
  
  
  
      def onFrameConfigure(self, event):
          '''Reset the scroll region to encompass the inner frame'''
          self.canvas.configure(scrollregion=self.canvas.bbox("all"))
  
  if __name__ == "__main__":
      root=tk.Tk()
      Example(root).pack(side="top", fill="both", expand=True)
      root.mainloop()
  </code></pre>
  
  <p>and this: 
  <a href="https://stackoverflow.com/questions/1844995/how-to-add-a-scrollbar-to-a-window-with-tkinter">How to add a scrollbar to a window with tkinter?</a> 
   that is not organise like a class.</p>
  
  <p>how can i implement the 2 scrollbars?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>new version:</p>
  
  <pre><code>from win32com.client import Dispatch
  from tkinter import *
  from tkinter import ttk
  import tkinter
  
  
  class applicazione:
  
  
      def __init__(self, root):
          self.root = root
  
          # Top-level frame
  
          self.frame = ttk.Frame(self.root, relief="sunken")
  
          # Canvas creation with double scrollbar
          hscrollbar = ttk.Scrollbar(self.frame, orient = tkinter.HORIZONTAL)
          vscrollbar = ttk.Scrollbar(self.frame, orient = tkinter.VERTICAL)
          self.canvas = tkinter.Canvas(self.frame, bd=0, highlightthickness=0, yscrollcommand = vscrollbar.set, xscrollcommand = hscrollbar.set)
          vscrollbar.config(command = self.canvas.yview)
          hscrollbar.config(command = self.canvas.xview)
  
  
          # Add controls here
          self.subframe = ttk.Frame(self.canvas)
  
          #Packing everything
          self.subframe.pack(padx   = 15, pady   = 15, fill = tkinter.BOTH, expand = tkinter.TRUE)
          hscrollbar.pack( fill=tkinter.X, side=tkinter.BOTTOM, expand=tkinter.FALSE)
          vscrollbar.pack( fill=tkinter.Y, side=tkinter.RIGHT, expand=tkinter.FALSE)
          self.canvas.pack(side = tkinter.LEFT, padx  = 5, pady   = 5, fill = tkinter.BOTH, expand= tkinter.TRUE)
          self.frame.pack( padx   = 5, pady   = 5, expand = True, fill = tkinter.BOTH)
  
  
          self.canvas.create_window(0,0, window = self.subframe)
          self.root.update_idletasks() # update geometry
          self.canvas.config(scrollregion = self.canvas.bbox("all"))
          self.canvas.xview_moveto(0) 
          self.canvas.yview_moveto(0)
  
  
          self.root.title('Controllo dati per fatturazione elettronica - Manticle - Smith &amp; Nephew Italia')
          ttk.Frame(self.root, width=300, height=250).pack()
  
  
          #### Titles
          self.titoli_HFT = ["Dest_Cod_FIS_P_Iva", "Cod_Cli", "Dest_RagSoc1", "Dest_RagSoc2",
                             "Dest_Indirizzo", "Dest_CAP", "Dest_Localita", "Dest_Provincia", "Cli_Cod_Fis_P_Iva",
                              "Cod_Dest", "Cli_RagSoc1", "Cli_RagSoc2", "Cli_Indirizzo", "Cli_CAP",
                             "Cli_Localita", "Cli_Provincia", "Tipo_Doc", "pre_Num_Doc", "Num_Doc",
                              "Data_Doc", "Vs_Rif", "Data_Rif", "Blank", "Blank2", "CPT", "Scad_Pagamento",
                             "Descr", "Num_Ord", "Tot_Imp", "Tot_IVA", "Tot_Doc", "Nazione", "IPA", "Reg_Fiscale"]
  
  
  
          self.inizializza_widgets()
  
  
      def inizializza_widgets(self):
  
          self.lblins=tkinter.Label(self.root, text="Controllo dati per fatturazione elettronica", font=("Helvetica", 12))
          self.lblins.place(x=10, y=10)
  
          for i in range (0,len(self.titoli_HFT)):
              j = 80*i
              self.lblnome=tkinter.Label(self.root, text= self.titoli_HFT[i], font=("Helvetica", 8))
              self.lblnome.place(x=85+j, y=50)
  
          ttk.Button(self.root, text='Inserisci', width='10').place(x=645, y=590)
  
          ttk.Button(self.root, text='Modifica', width='10').place(x=725, y=590)
  
          ttk.Button(self.root,  text='Indietro', width='10').place(x=805, y=590)
  
          ttk.Button(self.root,  text='Avanti', width='10').place(x=885, y=590)
  
  
  
  if __name__ == '__main__':
      root = tkinter.Tk()
      root.title( "Double scrollbar with tkinter" )
      w, h = root.winfo_screenwidth(), root.winfo_screenheight()
      root.geometry("%dx%d+0+0" % (w, h))
      applicazione(root)
      root.mainloop()
  </code></pre>