Skip to content

Commit

Permalink
Updated the imported traits.api.Range in RangeEditorDemo.py with the …
Browse files Browse the repository at this point in the history
…show_error_dialog attribute set to False in order to avoid that the popup error dialog blocks and eventually makes the TestRangeEditorDemo fail.
  • Loading branch information
pbrod committed Nov 23, 2021
1 parent b186223 commit c6e0cd3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
35 changes: 34 additions & 1 deletion traitsui/examples/demo/Standard_Editors/RangeEditor_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,42 @@
.. _RangeEditor API docs: https://docs.enthought.com/traitsui/api/traitsui.editors.range_editor.html#traitsui.editors.range_editor.RangeEditor
"""

from traits.api import HasTraits, Range
from traits.api import HasTraits, Range as _Range
from traitsui.api import Item, Group, View


# TODO: Update traits.api.Range with the following in order to avoid the popup-error-dialog.
# TODO: Remove redefinition of Range here once the traits.api.Range is updated.
class Range(_Range):
def create_editor(self):
""" Returns the default UI editor for the trait.
"""
# fixme: Needs to support a dynamic range editor.

auto_set = self.auto_set
if auto_set is None:
auto_set = True
show_error_dialog = self.show_error_dialog
if show_error_dialog is None:
show_error_dialog = True

from traitsui.api import RangeEditor
return RangeEditor(
self,
mode=self.mode or "auto",
cols=self.cols or 3,
auto_set=auto_set,
enter_set=self.enter_set or False,
low_label=self.low or "",
high_label=self.high or "",
low_name=self._low_name,
high_name=self._high_name,
show_error_dialog=show_error_dialog
)




class RangeEditorDemo(HasTraits):
"""Defines the RangeEditor demo class."""

Expand All @@ -41,6 +73,7 @@ class RangeEditorDemo(HasTraits):
large_int_range = Range(1, 150, show_error_dialog=False)
float_range = Range(0.0, 150.0, show_error_dialog=False)


# RangeEditor display for narrow integer Range traits (< 17 wide):
int_range_group1 = Group(
Item(
Expand Down
3 changes: 1 addition & 2 deletions traitsui/qt4/range_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,7 @@ def _make_button_high(self, high):
return button_hi

def _set_slider(self, value):
""" Updates the slider range controls.
"""
"""Updates the slider range controls."""
low, high = self._get_current_range()
if not low <= value <= high:
low, high = self.init_current_range(value)
Expand Down

0 comments on commit c6e0cd3

Please sign in to comment.