Eto Slider Values don't update dynamically with python

Hi everyone,
I am learning the python eto. I set the default value as 3. However, I found three problems. You may check the attached figure

  1. the line doesn’t change when i am sliding the slider value dynamically. I need to close the window first to make changes
  2. the current value of the slider is always the default value, not the value i set last time.
  3. I cannot adjust the viewport on rhino when the window is on.

Also, I am new to python eto. I found a little resource to learn online, could anyone give some suggestion in learning eto?

thanks in advance

anyone help? =’(

Hi @raylee14,

from your screenshot it will be very hard to help, as a lot of the code is missing.

You should definitely subscribe to the slider ValueChanged Event, to see live updates when updating the slider, see:

Also line 25 seems to be not right:

objeto.m_slider.Value = objeto.m_slider.Value

is just setting the value to itself, probably you want to refernece another value there

1 Like

Thanks for the reply.
I have modified the code a little bit.
What i wanna do is to change the geometries’ parameters with eto sliders. I hope I can see them changing when sliding the slider (i.e. the slider value keeps update). also, next time i open the slider form, it will be the value I set previously
And it would be great if I can change the viewport in Rhino windows when the eto form is on.
I have hard time to understand the methods’ manual because they do not provide python codes
/ ____ \


import Rhino
import System
import Rhino.UI
import Eto.Drawing as drawing
import Eto.Forms as forms

class EtoSliderForm(forms.Form):

    def __init__(self):
        self.Title = 'Eto Slider'
        self.Padding = drawing.Padding(10)
        self.Resizable = False
        self.Width = 500
        self.Height = 100

        self.m_slider = forms.Slider()
        self.m_slider.MinValue = 1
        self.m_slider.MaxValue = 50
        self.m_slider.Value = value
        self.m_slider.ValueChanged += self.OnSliderValueChanged

        layout = forms.DynamicLayout()
        layout.Spacing = drawing.Size(5, 5)

        self.Content = layout
    def OnSliderValueChanged(self, sender, e):

    def GetNumber(self):
        return self.m_slider.Value

if show:
    if 'form' in globals():
    form = EtoSliderForm();

if 'form' in globals():
    value = form.GetNumber()
if 'value' not in globals():
    value = 1
a = Rhino.Geometry.Circle(value) (5.2 KB)

If you want to interact with Rhino, you need to use a modeless form any modal form will block the parent forms.
If you use a modeless form you will face another problem, I don’t know why but it seems that TopMost property of Eto.Forms does not work as it supposes to.
Rhino.UI.EtoExtensions.ShowSemiModal() will allow the user to interact with the main Rhino window while keeping it on top but the problem is it will block grasshopper.
Long story short, there might be better approaches:

  • Human-UI
  • Eto.forms in Rhino Python with ShowSemiModal().
  • WinForms or WPF in GhPython or C# script.

Hi @raylee14,

Is there a specific reason you choose to run your own undocumented eto-in-grasshopper solution?
Maybe the HumanUI plugIn can do what you want to achieve, it would certainly be way easier to implement, see:

Some advice on your current solution:

  • An EtoView inheriting from Dialog is blocking the ui until closed, so you will never see live changes while it is open, you can’t even interact with grasshopper in any way while it is open
  • You would rather need to inherit from Form as this has a Modeless Show Method
  • You would also still need to subscribe to the sliders ValueChanged event, as I pointed out in my other answer
  • Subscribing to events is covered exhaustively in the devloper samples, read them to see how to do it, f.e:
  • If you get that working you will have tell your grasshopper scripting component to update its output, but if you just call SolveInstance it will re-compute again giving you more Forms vor every slider change event
  • So you will also need to store your view in the sc.sticky dictionary and do some logical if - else cases to get your results of the fired events

All in all using HumanUI would be a lot easier, or if you are interested in the Eto technology, try doing what the developer samples do first and build Rhino-Python scripts before tackling grasshopper as this will add an additional layer of complexity on top.

Well pretty much what @Mahdiyar is saying


Thank you so much !
This is really amazing =D

I got it. You guys solved all my problems
thanks again

btw, i found that the human ui has similar problems. it doesn’t update the slider’s value dynamically. and when i press refresh in grasshopper documents, all value will back to default value.
i struggle on this for a long time. i also try to control the number slider with its guid in ghpython, but it seems make a lot of errors and breakpoints
thats why i try eto
thanks again for the solution =)