Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5938

Trying to understand ETO button bound method

$
0
0

@Jun_Wang wrote:

I was reading this post on the rhino3d website and I was having problem understanding the way the bound method as described in the post is structure, copied below:

The bound method, listed later in the calss definition is run if the button is clicked.

    # Close button click handler
    def OnOKButtonClick(self, sender, e):
        if self.m_textbox.Text == "":
            self.Close(False)
        else:
            self.Close(True)

where does the sender and e input coming from? Do I ever have to change them and call/assign them?

self.m_button.Click += self.OnButtonClick

also on the subject, in the line above, it is explained in the post that:

an action is commonly attached through the .Click event. Use the += syntax as shown below to bind the action to button.

I’m not an expert in Python and could not understand why +=, which usually means equal to self in addition to *, can here used to bind action to a button, which is not that big of a deal, but do I ever have to use a different syntax for button binding in a specific scenario?

Thank you so much!

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 5938

Trending Articles