title: python tkinter button binding in canvas grid and adding scrollbar to canvas
body: <p>How can I get the scrollbar to show up on canvas.</p>
  
  <pre><code># python dashboard
  
  import tkinter as tk
  from tkinter import *
  
  #======================{{{
  class AutoScrollbar(Scrollbar):
      def set(self, lo, hi):
          if float(lo) &lt;= 0.0 and float(hi) &gt;= 1.0:
              self.tk.call("grid", "remove", self)
          else:
              self.grid()
          Scrollbar.set(self, lo, hi)
      def pack(self, **kw):
          raise TclError("cannot use pack with this widget")
      def place(self, **kw):
          raise TclError("cannot use place with this widget")
  #====}}}
  
  
  #===================={{{
  class Dashboard():
      def __init__(self, root):
          self.root=root
          root.title("Dashboard View")
  
          canvasContainer = tk.Frame(root)
          self.canvas=tk.Canvas(canvasContainer, width=1000, height=700,background='#002B36')
  
          canvasContainer.grid(row=0,column=3)
  
          frame = Frame(self.root, bd=2, relief=SUNKEN)
          frame.grid(row=0,column=0, sticky="nw")
  
          b1=Button(frame,text="Status", command=lambda color="#DC322F", filename="dashboard_content.txt" : self.contents(color,filename)).grid(row = 0,column = 0, sticky = "we")
          b2=Button(frame,text="Processes", command=lambda color="#859900", filename="process.log" : self.contents(color,filename)).grid(row = 0,column = 1, sticky = "we")
          b3=Button(frame,text="Links", command=lambda color="#B58900", filename="links.log" : self.contents(color,filename)).grid(row = 1,column = 0, sticky = "we")
          b4=Button(frame,text="Traffic", command=lambda color="#268BD2", filename="version.log" : self.contents(color,filename)).grid(row = 1,column = 1, sticky = "we")
          b5=Button(frame,text="App Version", command=lambda color="#D33682", filename="version.log" : self.contents(color,filename)).grid(row = 2,column = 0, sticky = "we")
          b6=Button(frame,text="Archive/Purge", command=lambda color="#93A1A1", filename="cleanup.log" : self.contents(color,filename)).grid(row = 2,column = 1, sticky = "we")
  
  #        self.contents("blue","dashboard_content.txt")
  #        b1.bind("&lt;ButtonPress-1&gt;", lambda events, color="blue", filename="dashboard_content.txt" : self.contents(color,filename))
  
          vsb = AutoScrollbar(canvasContainer,orient=VERTICAL)
          hsb = AutoScrollbar(canvasContainer, orient=HORIZONTAL)
          vsb.grid(row=0, column=2, sticky="ns")
          hsb.grid(row=1, column=1, sticky="ew")
          self.canvas.grid(row=0,column=1,sticky="news")
          self.canvas.config(yscrollcommand=vsb.set, xscrollcommand=hsb.set, scrollregion=self.canvas.bbox("all"))
  
          vsb.config(command=self.canvas.yview)
          hsb.config(command=self.canvas.xview)
  
          canvasContainer.grid_rowconfigure(0, weight=1)
          canvasContainer.grid_columnconfigure(0, weight=1)
  
          self.canvas.update_idletasks()
  #        Grid.columnconfigure(self.root,1,weight=1, minsize=100)
  
      def contents(self, color="blue", filename="dashboard_content.txt"):
          fhandle = open(filename)
          lines = fhandle.read()
          fhandle.close()
          self.canvas.delete("all")
          text1=self.canvas.create_text(0, 0, fill=color, anchor=NW)
          self.canvas.itemconfig(text1, text=lines)
  
  #===========}}}
  
  if __name__== '__main__':
      root=tk.Tk()
      board=Dashboard(root)
      root.mainloop()
  </code></pre>
  
  <p>If I don't have the contents function, the scrollbar appears. How Can I have a scrollbar around canvas in this case.</p>