Next / Previous / Contents

22.1. The Scrollbar command callback

When the user manipulates a scrollbar, the scrollbar calls its command callback. The arguments to this call depend on what the user does:

  • When the user requests a movement of one “unit” left or up, for example by clicking button B1 on the left or top arrowhead, the arguments to the callback look like:

        command(tk.SCROLL, -1, tk.UNITS)
    
  • When the user requests a movement of one unit right or down, the arguments are:

        command(tk.SCROLL, 1, tk.UNITS)
    
  • When the user requests a movement of one page left or up:

        command(tk.SCROLL, -1, tk.PAGES)
    
  • When the user requests a movement of one page right or down:

        command(tk.SCROLL, 1, tk.PAGES)
    
  • When the user drags the slider to a value f in the range [0,1], where 0 means all the way left or up and 1 means all the way right or down, the call is:

        command(tk.MOVETO, f)
    

These calling sequences match the arguments expected by the .xview() and .yview() methods of canvases, listboxes, and text widgets. The Entry widget does not have an .xview() method. See Section 10.1, “Scrolling an Entry widget”.