Eto - simple direct binding example

Hi to all python scripters,

attached is a (hopefully comprehensable) example script for direct binding between a slider control and a numeric stepper. The important line of code is:

self.numeric.ValueBinding.Bind(self.slider, "Value", Eto.Forms.DualBindingMode.TwoWay)

ETO_SliderNumericBinding.py (2.1 KB)

happy coding,
c.

3 Likes

Hi @curtisw and @Trav,

i would like to do the same as the simple example above but my value range is between 0.0 and 1.0. The numeric stepper supports that range but the slider requires integers. Is there a way to include such a conversion in the ValueBinding ?

thanks,
c.

Hi @clement,

To convert types, you can use the Convert() method, something like this, assuming the numeric is set to a range from 0.0-1.0, and the slider is 0-100:

self.numeric.ValueBinding.Convert(lambda i: i * 100, lambda d: d / 100.0).Bind(self.slider, "Value")

Hope this helps!

2 Likes

Thank you @curtisw. it works.

_
c.