from Tkinter import * global e def calc(): i = int(str(e.get())) print 'Given %d:\n >' % (i), va = 4.0 vb = 1.0 vc = 1.0 vd = 0.0 for y in range(i): ve = float(va / vb) vd += vc * ve vc = vc * -1 vb += 2 print '%f' % (vd) 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()