If there are lets say 4 buttons, all with the same Click event, how can I find out which button was pressed?
if the event looks like this def Button_Click(self, sender, e): I’m sure I can compare sender to my buttons somehow. But how?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well, I’ve never used IronPython so I don’t know how much help this will be, but what I usually do when trying to figure out these things in regular python is to
print type(sender),print senderandprint dir(sender)to console(or output to a file if you don’t have a console available).This should help you figure out what exactly is the “sender” parameter. In the simplest case it could be the button itself so a simple
==will work to know which button it was. Or it could have a method/property that gets you the button object. In which case,dir(sender)might contain an obvious one, or if not, google the class name gotten fromtype(sender)and see if you can find any docs.