Ch. Sohaib
Ch. Sohaib

Reputation: 13

Call Back not running

My code :-

def load():
    label.configure(text="Error")
button = tkinter.Button(main,width=8,text="Continue >", command="load")

and the window is running perfectly but the callback is not running, I have tried many kind of callbacks like printing configuring etc. but didn't worked. What is solution?

Upvotes: 0

Views: 46

Answers (2)

Madhusudan chowdary
Madhusudan chowdary

Reputation: 553

In your code you passed load as a string .So it doesn't work. Because command in the sense what command should be performed when the component Button is clicked. So try to change it don't pass it as a string .

Change it as

button = tkinter.Button(main,width=8,text="Continue >", command=load)

Upvotes: 1

omri_saadon
omri_saadon

Reputation: 10671

The command argument is expecting to have a function, Not a string.

Instead of string, use the the function.

Instead of:

button = tkinter.Button(main,width=8,text="Continue >", command="load")

write:

button = tkinter.Button(main,width=8,text="Continue >", command=load)

Upvotes: 1

Related Questions