python - Usage of BoundsEditor in TraitsUI -
i want use boundseditor (in traitsui) range selection. how access high , low values? testing use rangeeditor - works expected (on moving slider current value printed). cannot values out of boundseditor. pointers appreciated.
i use following (simplified code):
from traits.api \ import hastraits, button, range traitsui.api \ import view, item, group, rangeeditor traitsui.qt4.extra.bounds_editor import boundseditor class parameters(hastraits): rgb_range = range(0.,1.0) range1 = rgb_range range2 = rgb_range eval_button = button("eval") traits_view= view( item('range1')), #editor=rangeeditor() item('range2', editor=boundseditor()), item('eval_button')) def _range1_changed(self, value): print(value) def _range2_changed(self, *arg, **kwargs): print(arg) def _range2_changed(self, *arg, **kwargs): print(arg) def _range2_low_changed(self, *arg, **kwargs): print(arg) def _range2_high_changed(self, *arg, **kwargs): print(arg) def _eval_button_fired(self): print(self.range1) print(self.range2) if __name__ == '__main__': alg = parameters() alg.configure_traits()
i beginning learn traits, sure else can explain better me. using example http://blog.enthought.com/enthought-tool-suite/traits/new-double-slider-editor/#.vgfbyltgtwq. declared variables low , high values, , passed these boundseditor(). declared functions run when values change. got think close looking for.
from traits.api \ import hastraits, button, range, float traitsui.api \ import view, item, group, rangeeditor traitsui.qt4.extra.bounds_editor import boundseditor class parameters(hastraits): rgb_range = range(0.,1.0) range1 = rgb_range range2 = rgb_range low_val = float(0.0) high_val = float(1.0) eval_button = button("eval") traits_view= view( item('range1', editor=rangeeditor()), item('range2', editor=boundseditor(low_name = 'low_val', high_name = 'high_val')), item('eval_button')) def _range1_changed(self, value): print(value) def _low_val_changed(self): print(self.low_val) def _high_val_changed(self): print(self.high_val) def _eval_button_fired(self): print(self.range1) print(self.low_val) print(self.high_val) if __name__ == '__main__': alg = parameters() alg.configure_traits()
Comments
Post a Comment