from Tkinter import * global e def calc(): i = int(str(e.get())) y = 1 v = 0 r = ((i*4) + 1) for y in range(r): y +=4 v = v+((1/y) - (1/(y +2))) print v*4 window = Tk() lbl = Label(window, text='How many iterations?') lbl.pack(side=TOP) e = Entry(name='text') e.pack(expand = YES, fill = BOTH) b = Button(window, text='Calculate', command=calc) b.pack(side=BOTTOM) window.mainloop()