tkinter - How to give an "argument" to my function in Python? -


i using python 2.7 , tkinter. trying make button change own text when clicked. code seems correct, keep encountering error:

exception in tkinter callback traceback (most recent call last):   file "/usr/lib/python2.7/lib-tk/tkinter.py", line 1413, in __call__     return self.func(*args) typeerror: dostuff takes 1 argument (0 given) 

here code:

def dostuff(event):     button01.configure(command=dostuff2)     button01.configure(text="click me again!")  button01 = button(root, text="click me", command=dostuff) button01.grid(row=8, column=6) 

where screwing , how pass needed argument dostuff()?

you defined function taking event. for? have bound keyboard key? keyboard key, when pressed, pass event whatever function it's bound to. however, button widget not. if function connected button, remove event function definition.

if have bound function both button , keyboard key (or mouse action, or else generates event), give default argument def dostuff(event=none):.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -