#!/usr/local/bin/python
import Tkinter as Tk

root = Tk.Tk()
def printme1(value):
	print 'Scale # 1 just fired with value:', value
scalevar = Tk.IntVar()
scalevar.set(7)
scale1 = Tk.Scale(root, command=printme1, variable=scalevar)
print 'Scale #1 initialized with value:', scale1.get()

def printme2(value):
	print 'Scale # 2 just fired with value:', value
scale2 = Tk.Scale(root)
print 'Scale #2 initialized with value: ', scale2.get()
scale2.set(4)
print 'Scale #2 just set to value: ', scale2.get()
scale2.configure(command=printme2)

def printme3():
	print 'Checkbutton # 1 just fired with value:', cbvar.get()
cbvar = Tk.IntVar()
cbvar.set(1)
cb1 = Tk.Checkbutton(root, variable=cbvar, command=printme3)
print 'Checkbutton #1 initialized with value: ', cbvar.get()

def printme4():
	print 'Checkbutton # 2 just fired with value:', cbvar2.get()
cbvar2 = Tk.IntVar()
cbvar2.set(1)
cb2 = Tk.Checkbutton(root, variable=cbvar)
cb2.invoke()
print 'Just invoked cb2 with no callback'
cb2.configure(command=printme4)

print 'Now packing scales'
scale1.pack()
scale2.pack()
cb1.pack()
print 'Done packing scales'

root.mainloop()

