By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,171 Members | 776 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,171 IT Pros & Developers. It's quick & easy.

What is the difference between "command" option and bind method?

P: 13
what is the difference between "command" option and bind method,
and what is the purpose of passing event object in callback methods
Expand|Select|Wrap|Line Numbers
  1. def callback(event):
  2.               pass
Oct 27 '11 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 2.5K+
P: 2,851
A Tkinter Button can be configured with a command callback. The callback function is executed when the button is pushed.
Expand|Select|Wrap|Line Numbers
  1. Button(frame, text="Exit", fg="green", bg="black", command=master.destroy)
A Tkinter Button can be bound to an event such as "<ButtonRelease-1>". In effect it would behave in a similar manner in the example:
Expand|Select|Wrap|Line Numbers
  1. btn = Button(frame, text="Exit", fg="green", bg="black")
  2. btn.bind(sequence="<ButtonRelease-1>", func=master.destroy)
The difference in the bound event is function master.destroy must be defined to receive an argument event The event object event carries a lot of information.
Oct 27 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.