# L-30 MCS 260 Mon 5 Nov 2007 : guiradio.py # # Use of Radiobutton to do +1 or -1. from Tkinter import * top = Tk() top.title("use Radiobutton") text = Entry(top) text.insert(INSERT,"0") # initialization text.grid(row=0,columnspan=2) def plus(): "Callback function, does +1" s = text.get() # data in Entry s = str(int(s) + 1) # add one to it text.delete(0,END) # clear Entry text.insert(INSERT,s) # insert result def minus(): "Callback function does -1" s = text.get() s = str(int(s) - 1) text.delete(0,END) text.insert(INSERT,s) add = Radiobutton(top,text="+1",\ command=plus) add.grid(row=1,column=0) sub = Radiobutton(top,text="-1",\ command=minus) sub.grid(row=1,column=1) top.mainloop()