Reputation: 3632
I'm wondering how to add more information to an event embed in a button.
For example:
okButton = ttk.Button( content, text = 'OK' )
okButton.bind( "<Button-1>", browseFile )
def browseFile( event ):
pass
When the button clicked, I want to pass the string parameter 'OK' to the function browseFile
, what I need to do?
Thanks
Upvotes: 0
Views: 306
Reputation: 76184
The event
object has a widget
member that identifies the widget that raised the event. You can get the text of that widget using the cget
method:
def browseFile(event):
buttonText = event.widget.cget("text")
if buttonText == "OK":
doSomeStuff()
Upvotes: 3