# L-32 MCS 260 Fri 1 Apr 2016 : exscale0.py

"""
Extending our first example with an entry and a button.
"""

from tkinter import Tk, DoubleVar, Scale, Button
from tkinter import Entry, END, INSERT

TOP = Tk()
TOP.title('example of a scale')
LOW = 0.0
HIGH = 1.0
VAR = DoubleVar()
SCL = Scale(TOP, orient='horizontal', \
    from_=LOW, to=HIGH, \
    tickinterval=(HIGH-LOW)/5.0, \
    resolution=(HIGH-LOW)/1000.0, \
    length=300, variable=VAR)
SCL.grid(row=0, columnspan=2)

ENT = Entry(TOP)
ENT.grid(row=1, column=0)

def show_value():
    """
    Displays the value of scale variable Var
    in the entry widget ENT.
    """
    ENT.delete(0, END)
    ENT.insert(INSERT, VAR.get())

BTT = Button(TOP, text="show value", \
    command=show_value)
BTT.grid(row=1, column=1)
TOP.mainloop()
