# L-32 MCS 260 Fri 9 Nov 2007 : exscale2.py # # The third example of a scale uses the command # argument in the scale widget and does not need # the value button. from Tkinter import * class ShowScale(): """ GUI to demonstrate use of a scale. """ def __init__(self,wdw): "determines the layout of the GUI" wdw.title('example of a scale') self.low = 0.0 self.high = 1.0 self.f = DoubleVar() self.s = Scale(wdw,\ orient='horizontal',\ from_=self.low,to=self.high,\ tickinterval=(self.high-self.low)/5.0,\ resolution=(self.high-self.low)/1000.0,\ length=300,variable=self.f,\ command=self.ShowValue) self.s.grid(row=0,column=0) self.e = Entry(wdw) self.e.grid(row=1,column=0) def ShowValue(self,v): "shows the value of the scale variable" self.e.delete(0,END) sv = 'value = ' + str(v) self.e.insert(INSERT,sv) def main(): top = Tk() show = ShowScale(top) top.mainloop() if __name__ == "__main__": main()