From dd82eeccf77eaa26018ce1e6a504cf8d97929b7f Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Fri, 11 Jun 2021 16:22:30 -0500 Subject: [PATCH 01/15] add a currently failing test --- traitsui/tests/editors/test_range_editor.py | 31 +++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/traitsui/tests/editors/test_range_editor.py b/traitsui/tests/editors/test_range_editor.py index a12c5f7b3..0b5bebabc 100644 --- a/traitsui/tests/editors/test_range_editor.py +++ b/traitsui/tests/editors/test_range_editor.py @@ -320,3 +320,34 @@ def test_modify_slider_log_range_slider(self): displayed = text.inspect(DisplayedText()) self.assertEqual(model.float_value, 10.0) self.assertEqual(displayed, str(model.float_value)) + + def test_format_func(self): + + def num_to_time(num): + minutes = int(num / 60) + if minutes < 10: + minutes_str = '0' + str(minutes) + else: + minutes_str = str(minutes) + seconds = num % 60 + if seconds < 10: + seconds_str = '0' + str(seconds) + else: + seconds_str = str(seconds) + return minutes_str + ':' + seconds_str + + model = RangeModel() + view = View( + Item( + "float_value", + editor=RangeEditor(format_func=num_to_time) + ) + ) + model.configure_traits(view=view) + tester = UITester() + with tester.create_ui(model, dict(view=view)) as ui: + float_value_field = tester.find_by_name(ui, "float_value") + float_value_text = float_value_field.locate(Textbox()) + self.assertEqual( + float_value_text.inspect(DisplayedText()), "00:00.1" + ) From cf42ce447109fb122daff35a4c77c3b39d019a91 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Fri, 11 Jun 2021 16:31:05 -0500 Subject: [PATCH 02/15] remove call to configure_traits --- traitsui/tests/editors/test_range_editor.py | 1 - 1 file changed, 1 deletion(-) diff --git a/traitsui/tests/editors/test_range_editor.py b/traitsui/tests/editors/test_range_editor.py index 0b5bebabc..9b02474d1 100644 --- a/traitsui/tests/editors/test_range_editor.py +++ b/traitsui/tests/editors/test_range_editor.py @@ -343,7 +343,6 @@ def num_to_time(num): editor=RangeEditor(format_func=num_to_time) ) ) - model.configure_traits(view=view) tester = UITester() with tester.create_ui(model, dict(view=view)) as ui: float_value_field = tester.find_by_name(ui, "float_value") From d25a17fe461f1f342b8efc952c248b61df46bb3f Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Fri, 11 Jun 2021 16:31:36 -0500 Subject: [PATCH 03/15] make test pass on qt by using the string_value method on the factory --- traitsui/qt4/range_editor.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/traitsui/qt4/range_editor.py b/traitsui/qt4/range_editor.py index 37741ae2b..6a668eace 100644 --- a/traitsui/qt4/range_editor.py +++ b/traitsui/qt4/range_editor.py @@ -111,7 +111,7 @@ def init(self, parent): try: if not (self.low <= fvalue <= self.high): fvalue = self.low - fvalue_text = self.format % fvalue + fvalue_text = self.factory.string_value(fvalue) except: fvalue_text = "" fvalue = self.low @@ -153,11 +153,11 @@ def init(self, parent): low_label = factory.low_label if factory.low_name != "": - low_label = self.format % self.low + low_label = self.factory.string_value(self.low) high_label = factory.high_label if factory.high_name != "": - high_label = self.format % self.high + high_label = self.factory.string_value(self.high) self._label_lo.setText(low_label) self._label_hi.setText(high_label) @@ -171,7 +171,7 @@ def update_object_on_scroll(self, pos): """ Handles the user changing the current slider value. """ value = self._convert_from_slider(pos) - self.control.text.setText(self.format % value) + self.control.text.setText(self.factory.string_value(value)) try: self.value = value except Exception as exc: @@ -221,7 +221,7 @@ def update_editor(self): low = self.low high = self.high try: - text = self.format % value + text = self.factory.string_value(value) 1 / (low <= value <= high) except: text = "" @@ -250,7 +250,7 @@ def _low_changed(self, low): self.value = int(low) if self._label_lo is not None: - self._label_lo.setText(self.format % low) + self._label_lo.setText(self.factory.string_value(low)) self.update_editor() def _high_changed(self, high): @@ -261,7 +261,7 @@ def _high_changed(self, high): self.value = int(high) if self._label_hi is not None: - self._label_hi.setText(self.format % high) + self._label_hi.setText(self.factory.string_value(high)) self.update_editor() def _convert_to_slider(self, value): From fc9ae3997126599a90d1601d6752e9a1f41425fe Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Fri, 11 Jun 2021 16:37:05 -0500 Subject: [PATCH 04/15] make same fix on wx --- traitsui/wx/range_editor.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/traitsui/wx/range_editor.py b/traitsui/wx/range_editor.py index 8bcccef75..64a6910ba 100644 --- a/traitsui/wx/range_editor.py +++ b/traitsui/wx/range_editor.py @@ -111,7 +111,7 @@ def init(self, parent): fvalue = self.low else: try: - fvalue_text = self.format % fvalue + fvalue_text = self.factory.string_value(fvalue) except (ValueError, TypeError) as e: fvalue_text = "" @@ -157,11 +157,11 @@ def init(self, parent): low_label = factory.low_label if factory.low_name != "": - low_label = self.format % self.low + low_label = self.factory.string_value(self.low) high_label = factory.high_label if factory.high_name != "": - high_label = self.format % self.high + high_label = self.factory.string_value(self.high) self._label_lo.SetLabel(low_label) self._label_hi.SetLabel(high_label) @@ -191,7 +191,7 @@ def update_object_on_scroll(self, event): ): try: self.ui_changing = True - self.control.text.SetValue(self.format % value) + self.control.text.SetValue(self.factory.string_value(value)) self.value = value except TraitError: pass @@ -253,7 +253,7 @@ def update_editor(self): """ value = self.value try: - text = self.format % value + text = self.factory.string_value(value) 1 // (self.low <= value <= self.high) except: text = "" @@ -296,7 +296,7 @@ def _low_changed(self, low): self.value = int(low) if self._label_lo is not None: - self._label_lo.SetLabel(self.format % low) + self._label_lo.SetLabel(self.factory.string_value(low)) self.update_editor() def _high_changed(self, high): @@ -307,7 +307,7 @@ def _high_changed(self, high): self.value = int(high) if self._label_hi is not None: - self._label_hi.SetLabel(self.format % high) + self._label_hi.SetLabel(self.factory.string_value(high)) self.update_editor() From 303206538de18ad934ea98ccc1b604fd61f11427 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Fri, 11 Jun 2021 16:52:25 -0500 Subject: [PATCH 05/15] redefine string_value method on RangeEditor to preserve behavior. We should be using format not format_str in this casee --- traitsui/editors/range_editor.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/traitsui/editors/range_editor.py b/traitsui/editors/range_editor.py index 42a21cbd8..6799d1bf6 100644 --- a/traitsui/editors/range_editor.py +++ b/traitsui/editors/range_editor.py @@ -284,6 +284,30 @@ def custom_editor(self, ui, object, name, description, parent): ) return super().custom_editor(ui, object, name, description, parent) + def string_value(self, value, format_func=None): + """ Returns the text representation of a specified object trait value. + + If the **format_func** attribute is set on the editor factory, then + this method calls that function to do the formatting. If the + **format** attribute is set on the editor factory, then this + method uses that string for formatting. If neither attribute is + set, then this method just calls the appropriate text type to format. + + This is slightly modified for the base EditorFactory inplementation to + use this class' ``format`` trait, as opposed to the ``format_str`` + trait defined on the base class. + """ + if self.format_func is not None: + return self.format_func(value) + + if self.format != "": + return self.format_str % value + + if format_func is not None: + return format_func(value) + + return str(value) + # This alias is deprecated and will be removed in TraitsUI 8. ToolkitEditorFactory = RangeEditor From 017714b793c09ec2af1463304cc623296e8cda9a Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Fri, 11 Jun 2021 16:58:02 -0500 Subject: [PATCH 06/15] add a test for use of format trait to ensure we aren't changing behavior --- traitsui/tests/editors/test_range_editor.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/traitsui/tests/editors/test_range_editor.py b/traitsui/tests/editors/test_range_editor.py index 9b02474d1..26fdc1c83 100644 --- a/traitsui/tests/editors/test_range_editor.py +++ b/traitsui/tests/editors/test_range_editor.py @@ -350,3 +350,19 @@ def num_to_time(num): self.assertEqual( float_value_text.inspect(DisplayedText()), "00:00.1" ) + + def test_format(self): + model = RangeModel() + view = View( + Item( + "float_value", + editor=RangeEditor(format="%s:%s") + ) + ) + tester = UITester() + with tester.create_ui(model, dict(view=view)) as ui: + float_value_field = tester.find_by_name(ui, "float_value") + float_value_text = float_value_field.locate(Textbox()) + self.assertEqual( + float_value_text.inspect(DisplayedText()), "0.1:0.1" + ) From 7383f0114a3d120daaffff7e890568c2988c51f8 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Fri, 11 Jun 2021 17:07:25 -0500 Subject: [PATCH 07/15] fix test and string_value method (missed one format_str) --- traitsui/editors/range_editor.py | 2 +- traitsui/tests/editors/test_range_editor.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/traitsui/editors/range_editor.py b/traitsui/editors/range_editor.py index 6799d1bf6..13cc6943e 100644 --- a/traitsui/editors/range_editor.py +++ b/traitsui/editors/range_editor.py @@ -301,7 +301,7 @@ def string_value(self, value, format_func=None): return self.format_func(value) if self.format != "": - return self.format_str % value + return self.format % value if format_func is not None: return format_func(value) diff --git a/traitsui/tests/editors/test_range_editor.py b/traitsui/tests/editors/test_range_editor.py index 26fdc1c83..935512c34 100644 --- a/traitsui/tests/editors/test_range_editor.py +++ b/traitsui/tests/editors/test_range_editor.py @@ -356,7 +356,7 @@ def test_format(self): view = View( Item( "float_value", - editor=RangeEditor(format="%s:%s") + editor=RangeEditor(format="%s ...") ) ) tester = UITester() @@ -364,5 +364,5 @@ def test_format(self): float_value_field = tester.find_by_name(ui, "float_value") float_value_text = float_value_field.locate(Textbox()) self.assertEqual( - float_value_text.inspect(DisplayedText()), "0.1:0.1" + float_value_text.inspect(DisplayedText()), "0.1 ..." ) From 9ad59b8cdada81a12f27b0a36ab2988b639e7bfb Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Fri, 11 Jun 2021 17:12:58 -0500 Subject: [PATCH 08/15] add news fragment --- docs/releases/upcoming/1684.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/releases/upcoming/1684.bugfix.rst diff --git a/docs/releases/upcoming/1684.bugfix.rst b/docs/releases/upcoming/1684.bugfix.rst new file mode 100644 index 000000000..fea78dd72 --- /dev/null +++ b/docs/releases/upcoming/1684.bugfix.rst @@ -0,0 +1 @@ +Add RangeEditor support for format_func (#1684) \ No newline at end of file From bb7a3c495fa93b36ecda48e391c6f9c0c8d36060 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Mon, 21 Jun 2021 10:08:13 -0500 Subject: [PATCH 09/15] deprecate format trait and make it an alias for format_str --- traitsui/editors/range_editor.py | 49 ++++++++++----------- traitsui/qt4/range_editor.py | 4 +- traitsui/tests/editors/test_range_editor.py | 13 +++--- traitsui/wx/range_editor.py | 2 - 4 files changed, 32 insertions(+), 36 deletions(-) diff --git a/traitsui/editors/range_editor.py b/traitsui/editors/range_editor.py index 13cc6943e..f127f215d 100644 --- a/traitsui/editors/range_editor.py +++ b/traitsui/editors/range_editor.py @@ -10,6 +10,7 @@ """ Defines the range editor factory for all traits user interface toolkits. """ +import warnings from types import CodeType @@ -64,8 +65,11 @@ class RangeEditor(EditorFactory): #: The name of an [object.]trait that defines the high value for the range high_name = Str() - #: Formatting string used to format value and labels - format = Str("%s") + # set format_str default + format_str = Str("%s") + + #: Deprecated: Formatting string used to format value and labels + format = Property(Str, observe='format_str') #: Is the range for floating pointer numbers (vs. integers)? is_float = Bool(Undefined) @@ -194,6 +198,23 @@ def _get_low_high(self, ui): # ------------------------------------------------------------------------- # Property getters. # ------------------------------------------------------------------------- + + def _get_format(self): + warnings.warn( + "Use of format trait is deprecated. Use format_str instead.", + DeprecationWarning, + stacklevel=2, + ) + return self.format_str + + def _set_format(self, format_string): + warnings.warn( + "Use of format trait is deprecated. Use format_str instead.", + DeprecationWarning, + stacklevel=2, + ) + self.format_str = format_string + def _get_simple_editor_class(self): """ Returns the editor class to use for a simple style. @@ -284,30 +305,6 @@ def custom_editor(self, ui, object, name, description, parent): ) return super().custom_editor(ui, object, name, description, parent) - def string_value(self, value, format_func=None): - """ Returns the text representation of a specified object trait value. - - If the **format_func** attribute is set on the editor factory, then - this method calls that function to do the formatting. If the - **format** attribute is set on the editor factory, then this - method uses that string for formatting. If neither attribute is - set, then this method just calls the appropriate text type to format. - - This is slightly modified for the base EditorFactory inplementation to - use this class' ``format`` trait, as opposed to the ``format_str`` - trait defined on the base class. - """ - if self.format_func is not None: - return self.format_func(value) - - if self.format != "": - return self.format % value - - if format_func is not None: - return format_func(value) - - return str(value) - # This alias is deprecated and will be removed in TraitsUI 8. ToolkitEditorFactory = RangeEditor diff --git a/traitsui/qt4/range_editor.py b/traitsui/qt4/range_editor.py index 6a668eace..277567c59 100644 --- a/traitsui/qt4/range_editor.py +++ b/traitsui/qt4/range_editor.py @@ -80,7 +80,7 @@ class SimpleSliderEditor(BaseRangeEditor): #: High value for the slider range high = Any() - #: Formatting string used to format value and labels + #: Deprecated: This trait is no longer used. format = Str() def init(self, parent): @@ -94,8 +94,6 @@ def init(self, parent): if not factory.high_name: self.high = factory.high - self.format = factory.format - self.evaluate = factory.evaluate self.sync_value(factory.evaluate_name, "evaluate", "from") diff --git a/traitsui/tests/editors/test_range_editor.py b/traitsui/tests/editors/test_range_editor.py index 935512c34..d3aa5ced8 100644 --- a/traitsui/tests/editors/test_range_editor.py +++ b/traitsui/tests/editors/test_range_editor.py @@ -352,13 +352,16 @@ def num_to_time(num): ) def test_format(self): + # format trait has been deprecated in favor of format_str. However, + # behavior should be unchanged. model = RangeModel() - view = View( - Item( - "float_value", - editor=RangeEditor(format="%s ...") + with self.assertWarns(DeprecationWarning): + view = View( + Item( + "float_value", + editor=RangeEditor(format="%s ...") + ) ) - ) tester = UITester() with tester.create_ui(model, dict(view=view)) as ui: float_value_field = tester.find_by_name(ui, "float_value") diff --git a/traitsui/wx/range_editor.py b/traitsui/wx/range_editor.py index 64a6910ba..c10cf64fb 100644 --- a/traitsui/wx/range_editor.py +++ b/traitsui/wx/range_editor.py @@ -91,8 +91,6 @@ def init(self, parent): if not factory.high_name: self.high = factory.high - self.format = factory.format - self.evaluate = factory.evaluate self.sync_value(factory.evaluate_name, "evaluate", "from") From f4fc4b037bc2568825d9a809539ecd29bcb79ff5 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Mon, 21 Jun 2021 10:21:03 -0500 Subject: [PATCH 10/15] add deprecation comment on wx --- traitsui/wx/range_editor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/traitsui/wx/range_editor.py b/traitsui/wx/range_editor.py index c10cf64fb..200c6960d 100644 --- a/traitsui/wx/range_editor.py +++ b/traitsui/wx/range_editor.py @@ -74,7 +74,7 @@ class SimpleSliderEditor(BaseRangeEditor): #: High value for the slider range high = Any() - #: Formatting string used to format value and labels + #: Deprecated: This trait is no longer used. format = Str() #: Flag indicating that the UI is in the process of being updated From a7304b06a7eb002e586c6febf1e30bd3d74e69b8 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Tue, 22 Jun 2021 15:29:30 -0500 Subject: [PATCH 11/15] add a test demonstrating behavior change --- traitsui/tests/editors/test_range_editor.py | 31 +++++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/traitsui/tests/editors/test_range_editor.py b/traitsui/tests/editors/test_range_editor.py index d3aa5ced8..6e131e24e 100644 --- a/traitsui/tests/editors/test_range_editor.py +++ b/traitsui/tests/editors/test_range_editor.py @@ -351,9 +351,11 @@ def num_to_time(num): float_value_text.inspect(DisplayedText()), "00:00.1" ) - def test_format(self): - # format trait has been deprecated in favor of format_str. However, - # behavior should be unchanged. + def test_editor_factory_format(self): + """ + format trait on RangeEditor editor factory has been deprecated in + favor of format_str. However, behavior should be unchanged. + """ model = RangeModel() with self.assertWarns(DeprecationWarning): view = View( @@ -369,3 +371,26 @@ def test_format(self): self.assertEqual( float_value_text.inspect(DisplayedText()), "0.1 ..." ) + + def test_editor_format(self): + """ + The format trait on an Editor instance previously potentially + could override the factory. Now that is not the case. + """ + model = RangeModel() + with self.assertWarns(DeprecationWarning): + view = View( + Item( + "float_value", + editor=RangeEditor(format="%s ...") + ) + ) + tester = UITester() + with tester.create_ui(model, dict(view=view)) as ui: + float_value_field = tester.find_by_name(ui, "float_value") + float_value_field._target.format = "%s +++" + model.float_value = 0.2 + float_value_text = float_value_field.locate(Textbox()) + self.assertEqual( + float_value_text.inspect(DisplayedText()), "0.2 ..." + ) From cd26554d7e90f51cab450ffa17b01d580a65bc11 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Tue, 22 Jun 2021 15:31:50 -0500 Subject: [PATCH 12/15] call string_value on the editor as this ends up calling the method on the factory anyway --- traitsui/qt4/range_editor.py | 14 +++++++------- traitsui/wx/range_editor.py | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/traitsui/qt4/range_editor.py b/traitsui/qt4/range_editor.py index 277567c59..329a949e8 100644 --- a/traitsui/qt4/range_editor.py +++ b/traitsui/qt4/range_editor.py @@ -109,7 +109,7 @@ def init(self, parent): try: if not (self.low <= fvalue <= self.high): fvalue = self.low - fvalue_text = self.factory.string_value(fvalue) + fvalue_text = self.string_value(fvalue) except: fvalue_text = "" fvalue = self.low @@ -151,11 +151,11 @@ def init(self, parent): low_label = factory.low_label if factory.low_name != "": - low_label = self.factory.string_value(self.low) + low_label = self.string_value(self.low) high_label = factory.high_label if factory.high_name != "": - high_label = self.factory.string_value(self.high) + high_label = self.string_value(self.high) self._label_lo.setText(low_label) self._label_hi.setText(high_label) @@ -169,7 +169,7 @@ def update_object_on_scroll(self, pos): """ Handles the user changing the current slider value. """ value = self._convert_from_slider(pos) - self.control.text.setText(self.factory.string_value(value)) + self.control.text.setText(self.string_value(value)) try: self.value = value except Exception as exc: @@ -219,7 +219,7 @@ def update_editor(self): low = self.low high = self.high try: - text = self.factory.string_value(value) + text = self.string_value(value) 1 / (low <= value <= high) except: text = "" @@ -248,7 +248,7 @@ def _low_changed(self, low): self.value = int(low) if self._label_lo is not None: - self._label_lo.setText(self.factory.string_value(low)) + self._label_lo.setText(self.string_value(low)) self.update_editor() def _high_changed(self, high): @@ -259,7 +259,7 @@ def _high_changed(self, high): self.value = int(high) if self._label_hi is not None: - self._label_hi.setText(self.factory.string_value(high)) + self._label_hi.setText(self.string_value(high)) self.update_editor() def _convert_to_slider(self, value): diff --git a/traitsui/wx/range_editor.py b/traitsui/wx/range_editor.py index 200c6960d..2fe943798 100644 --- a/traitsui/wx/range_editor.py +++ b/traitsui/wx/range_editor.py @@ -109,7 +109,7 @@ def init(self, parent): fvalue = self.low else: try: - fvalue_text = self.factory.string_value(fvalue) + fvalue_text = self.string_value(fvalue) except (ValueError, TypeError) as e: fvalue_text = "" @@ -155,11 +155,11 @@ def init(self, parent): low_label = factory.low_label if factory.low_name != "": - low_label = self.factory.string_value(self.low) + low_label = self.string_value(self.low) high_label = factory.high_label if factory.high_name != "": - high_label = self.factory.string_value(self.high) + high_label = self.string_value(self.high) self._label_lo.SetLabel(low_label) self._label_hi.SetLabel(high_label) @@ -189,7 +189,7 @@ def update_object_on_scroll(self, event): ): try: self.ui_changing = True - self.control.text.SetValue(self.factory.string_value(value)) + self.control.text.SetValue(self.string_value(value)) self.value = value except TraitError: pass @@ -251,7 +251,7 @@ def update_editor(self): """ value = self.value try: - text = self.factory.string_value(value) + text = self.string_value(value) 1 // (self.low <= value <= self.high) except: text = "" @@ -294,7 +294,7 @@ def _low_changed(self, low): self.value = int(low) if self._label_lo is not None: - self._label_lo.SetLabel(self.factory.string_value(low)) + self._label_lo.SetLabel(self.string_value(low)) self.update_editor() def _high_changed(self, high): @@ -305,7 +305,7 @@ def _high_changed(self, high): self.value = int(high) if self._label_hi is not None: - self._label_hi.SetLabel(self.factory.string_value(high)) + self._label_hi.SetLabel(self.string_value(high)) self.update_editor() From 68c42f14e7c815c9a1aaf16ec685a774e3459b92 Mon Sep 17 00:00:00 2001 From: aaronayres35 <36972686+aaronayres35@users.noreply.github.com> Date: Mon, 28 Jun 2021 04:40:41 -0700 Subject: [PATCH 13/15] Apply suggestions from code review Co-authored-by: Poruri Sai Rahul --- traitsui/editors/range_editor.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/traitsui/editors/range_editor.py b/traitsui/editors/range_editor.py index f127f215d..575fa9ac6 100644 --- a/traitsui/editors/range_editor.py +++ b/traitsui/editors/range_editor.py @@ -65,10 +65,11 @@ class RangeEditor(EditorFactory): #: The name of an [object.]trait that defines the high value for the range high_name = Str() - # set format_str default + #: Formatting string used to format value and labels format_str = Str("%s") - #: Deprecated: Formatting string used to format value and labels + #: Deprecated: Please use ``format_str`` instead. + #: Formatting string used to format value and labels. format = Property(Str, observe='format_str') #: Is the range for floating pointer numbers (vs. integers)? From d618dded67770b13b9559def168950fcfeff004c Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Mon, 28 Jun 2021 10:32:29 -0500 Subject: [PATCH 14/15] update news fragment --- docs/releases/upcoming/1684.bugfix.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/releases/upcoming/1684.bugfix.rst b/docs/releases/upcoming/1684.bugfix.rst index fea78dd72..85b229836 100644 --- a/docs/releases/upcoming/1684.bugfix.rst +++ b/docs/releases/upcoming/1684.bugfix.rst @@ -1 +1,2 @@ -Add RangeEditor support for format_func (#1684) \ No newline at end of file +Add RangeEditor support for format_func and deprecate ``format`` trait on +RangeEditor factory / toolkit specific Editor implementations (#1684) \ No newline at end of file From 2bf3fa5758260b62d1c448525e08332e90cf2371 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Mon, 28 Jun 2021 10:38:40 -0500 Subject: [PATCH 15/15] add comment refering to new issue --- traitsui/editors/range_editor.py | 1 + traitsui/qt4/range_editor.py | 2 +- traitsui/wx/range_editor.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/traitsui/editors/range_editor.py b/traitsui/editors/range_editor.py index 575fa9ac6..4cc03d81b 100644 --- a/traitsui/editors/range_editor.py +++ b/traitsui/editors/range_editor.py @@ -69,6 +69,7 @@ class RangeEditor(EditorFactory): format_str = Str("%s") #: Deprecated: Please use ``format_str`` instead. + #: See enthought/traitsui#1704 #: Formatting string used to format value and labels. format = Property(Str, observe='format_str') diff --git a/traitsui/qt4/range_editor.py b/traitsui/qt4/range_editor.py index 329a949e8..9904aff71 100644 --- a/traitsui/qt4/range_editor.py +++ b/traitsui/qt4/range_editor.py @@ -80,7 +80,7 @@ class SimpleSliderEditor(BaseRangeEditor): #: High value for the slider range high = Any() - #: Deprecated: This trait is no longer used. + #: Deprecated: This trait is no longer used. See enthought/traitsui#1704 format = Str() def init(self, parent): diff --git a/traitsui/wx/range_editor.py b/traitsui/wx/range_editor.py index 2fe943798..d09966bd9 100644 --- a/traitsui/wx/range_editor.py +++ b/traitsui/wx/range_editor.py @@ -74,7 +74,7 @@ class SimpleSliderEditor(BaseRangeEditor): #: High value for the slider range high = Any() - #: Deprecated: This trait is no longer used. + #: Deprecated: This trait is no longer used. See enthought/traitsui#1704 format = Str() #: Flag indicating that the UI is in the process of being updated