from Tkinter import * global edt1 def calc(): value = int(str(edt1.get())) i = 0 for i in range(value): print i window = Tk() lbl1=Label(window, text='How many iterations?') lbl1.pack(side=TOP) edt1=Entry(name='text') edt1.pack(expand = YES, fill = BOTH) btn1=Button(window, text='Calculate', command=calc()) bt1.pack(side=BOTTOM) window.mainloop()