Eto OnOKButtonClick custom argument

Good day,

I am working with Eto Forms. My goal is to have an interactive dialog that allowed to rotate different objects in Rhino.

After creating a series of buttons with a for loop:
image

image

I wish for every button to perform a rotation on a different element when its click on. So I thought about creating a method that takes i from the for loop as argument, something like this:

image

image

Nevertheless I am running into several errors while trying this method. I am thinking that the functions for onclickactions are only limited to three arguments (self, sender, e). Is this correct? or is there another way to allow to add arguments.

Thanks for your help :wink:

Juan

Set the Control.Tag Property on your Button and check it in your click handler.

I use that in Advanced Render Settings panel like so

and

You should be able to do something similar in Python for your case.

Thanks for your reply, Nathan.

The Control.Tag property is a great idea. I am working with it as follows:
image

And later in the click handler I am cheking its value like this:
image

When testing in Rhino, every time I click on the buttons I get the same number printed (the max of the range function).

Would you know a way, on how to get set a different value for the tag of each button, I have the feeling it is getting overwrite in the for loop.

Thanks again :blush:

Juan

You are creating num_elements buttons all in the same self.rotate variable. You should make self.rotate a list if you want to keep many numbers. But that still won’t help in the click handler.

Instead, you should look at sender, not self.rotate, in your click handler. That should be your Button, and will have the Tag property with the value you are looking for.

Amazing! it is working like a charm.

in case somebody else wants to follow the workflow:
image

image

When testing, after pressing each button I am able to print the i index associate with the Control.

Many many thanks,
Juan

2 Likes

Enjoy developing your tools!