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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ananth21
    New Member
    • Oct 2011
    • 13

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

    what is the difference between "command" option and bind method,
    and what is the purpose of passing event object in callback methods
    Code:
    def callback(event):
                  pass
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    A Tkinter Button can be configured with a command callback. The callback function is executed when the button is pushed.
    Code:
    Button(frame, text="Exit", fg="green", bg="black", command=master.destroy)
    A Tkinter Button can be bound to an event such as "<ButtonRel ease-1>". In effect it would behave in a similar manner in the example:
    Code:
    btn = Button(frame, text="Exit", fg="green", bg="black")
    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.

    Comment

    Working...