from Tkinter import *
class ScaleTest :
def CloseMe(self) :
self.value = self.scale.get()
self.root.destroy()
def ShowTheValue(self, args) :
self.value_label["text"] = str(self.scale.get())
def __init__(self) :
self.value = 0
self.root = Tk()
self.root.geometry("500x300")
self.scale = Scale( self.root, from_=0, to=100, orient=HORIZONTAL,showvalue=False,command=self.ShowTheValue )
self.scale.pack()
Button( self.root, text="Close", command=self.CloseMe ).pack()
self.value_label = Label( self.root, text="0" )
self.value_label.pack()
self.root.mainloop()
st = ScaleTest()
print "Value = " + str(st.value)
|