from Tkinter import * def response(event): I = event.widget['text'] texts = UPN.text.get(1.0,END+'-1c') #print texts if I == 'DEL': UPN.text.delete(INSERT + '-1c',INSERT) elif I == 'Clear': UPN.text.delete(1.0,END) elif I == 'Enter': PolishStyleGui.text.insert(INSERT,'\n') elif I == '=': s = toList(texts) #print s UPN.text.insert(END,'\n=\n') UPN.text.insert(END,f(s)) UPN.text.see('end') def UPN(): root.title('umgekehrte polnische Notation') root.resizable(False,False) root.geometry('400x500+200+100') UI = LabelFrame(root) UI.place(x = 1,y = 1,width = 398,height = 124) UPN.text = Text(UI) UPN.text.place(x=1,y=1,width=390,height=116) Li=[['7','8','9','+','DEL'], ['4','5','6','-','Enter'], ['1','2','3','*','='], ['0','00','.','/','Clear']] for i in range(len(Li[0])): for j in range(len(Li)): bt = Button(root) bt.place(x=(i+1)*60,y=120+(j+1)*60,width=50,height=50) bt['text'] = Li[j][i] bt.bind('',response,add=(root,))