ich habe ein kleines problem.
Das ist der dazugehörige Code:
Code: Alles auswählen
from Tkinter import*
i=0
def a(zahl):
global i
i+=1
print i
hf=Tk()
frame=Frame(hf,width=300,height=300)
frame.pack()
button=Button(frame,text='+1',command=a(1))
button.place(x=10,y=10)
button2=Button(frame,text='+2',command=a(2))
button2.place(x=30,y=30)
Weiß jemand, wie man das hinkriegt, das man trotzdem die Methode wie im Beispiel verwendet (spart code) aber die definition erst aufgerufen wird, wenn man auf den Button drückt?
Danke