# L-30 MCS 260 Mon 5 Nov 2007 : guicheck.py # # Illustrates use of Checkbutton. from Tkinter import * top = Tk() top.title("use Checkbutton") H = IntVar() # determined by hot button C = IntVar() # determined by cold button hot = Checkbutton(top,text="hot",\ variable = H,onvalue = 1,offvalue = 0) hot.grid(row=0,column=0) cold = Checkbutton(top,text="cold",\ variable = C,onvalue = 1,offvalue = 0) cold.grid(row=0,column=1) e = Entry(top) e.grid(row=2,columnspan=2) def act(): "callback function for enter button" e.delete(0,END) if H.get() == 1 and C.get() == 0: e.insert(INSERT,"it is hot") if H.get() == 0 and C.get() == 1: e.insert(INSERT,"it is cold") if H.get() == 1 and C.get() == 1: e.insert(INSERT,"it is hot and cold") b = Button(top,text = "enter",command=act) b.grid(row=1,columnspan=2,sticky=W+E+N+S) top.mainloop()