The Scale widget allows the user to select a numerical value by moving a “slider” knob along a scale.
Syntax:
S = Scale(root, bg, fg, bd, command, orient, from_, to, ..)
Option Parameters
root – root window.
bg – background colour
fg – foreground colour
bd – border
orient – orientation(vertical or horizontal)
from_ – starting value
to – ending value
troughcolor – set colour for trough.
state – decides if the widget will be responsive or unresponsive.
sliderlength – decides the length of the slider.
label – to display label in the widget.
highlightbackground – the colour of the focus when widget is not focused.
cursor – The cursor on the widget ehich could be arrow, circle, dot etc.
Methods
set(value) – set the value for scale.
get() – get the value of scale.
Example:
from Tkinter import *
master = Tk()
w = Scale(master, from_=0, to=100)
w.pack()
w = Scale(master, from_=0, to=200, orient=HORIZONTAL)
w.pack()
mainloop()
Tkinter Scrollbar
The Scrollbar widget is almost always used in conjunction with a Listbox, Canvas, or Text widget.
Syntax:
w = Scrollbar ( master, option, ... )
Here:
master − This represents the parent window.
options − Here is the list of most commonly used options for this widget.
Example;
from Tkinter import *
master = Tk()
scrollbar = Scrollbar(master)
scrollbar.pack(side=RIGHT, fill=Y)
listbox = Listbox(master, yscrollcommand=scrollbar.set)
for i in range(1000):
listbox.insert(END, str(i))
listbox.pack(side=LEFT, fill=BOTH)
scrollbar.config(command=listbox.yview)
mainloop()
There are many options which is used in this:
activebackground
bg
bd
cursor
elementborderwidth
highlightbackground
highlightcolor
highlightthickness
jump
orient
repeatdelay
repeatinterval
Use of these option
activebackground
The color of the slider and arrowheads when the mouse is over them.
bg
The color of the slider and arrowheads when the mouse is not over them.
bd
The width of the 3-d borders around the entire perimeter of the trough
command
A procedure to be called whenever the scrollbar is moved.
cursor
The cursor that appears when the mouse is over the scrollbar.
elementborderwidth
The width of the borders around the arrowheads and slider.
highlightbackground
The color of the focus highlight when the scrollbar does not have focus.
highlightcolor
The color of the focus highlight when the scrollbar has the focus.
orient
Set orient=HORIZONTAL for a horizontal scrollbar, orient=VERTICAL for a vertical one.