-
Notifications
You must be signed in to change notification settings - Fork 99
Add RangeEditor support for format_func #1684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
dd82eec
cf42ce4
d25a17f
fc9ae39
3032065
017714b
7383f01
9ad59b8
bb7a3c4
f4fc4b0
a7304b0
cd26554
68c42f1
d618dde
2bf3fa5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Add RangeEditor support for format_func (#1684) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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") | ||
|
|
||
|
|
@@ -111,7 +109,7 @@ def init(self, parent): | |
| try: | ||
| if not (self.low <= fvalue <= self.high): | ||
| fvalue = self.low | ||
| fvalue_text = self.format % fvalue | ||
| fvalue_text = self.string_value(fvalue) | ||
| except: | ||
| fvalue_text = "" | ||
| fvalue = self.low | ||
|
|
@@ -153,11 +151,11 @@ def init(self, parent): | |
|
|
||
| low_label = factory.low_label | ||
| if factory.low_name != "": | ||
| low_label = self.format % self.low | ||
| low_label = self.string_value(self.low) | ||
|
|
||
| high_label = factory.high_label | ||
| if factory.high_name != "": | ||
| high_label = self.format % self.high | ||
| high_label = self.string_value(self.high) | ||
|
|
||
| self._label_lo.setText(low_label) | ||
| self._label_hi.setText(high_label) | ||
|
|
@@ -171,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.format % value) | ||
| self.control.text.setText(self.string_value(value)) | ||
| try: | ||
| self.value = value | ||
| except Exception as exc: | ||
|
|
@@ -221,7 +219,7 @@ def update_editor(self): | |
| low = self.low | ||
| high = self.high | ||
| try: | ||
| text = self.format % value | ||
| text = self.string_value(value) | ||
| 1 / (low <= value <= high) | ||
| except: | ||
| text = "" | ||
|
|
@@ -250,7 +248,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.string_value(low)) | ||
| self.update_editor() | ||
|
|
||
| def _high_changed(self, high): | ||
|
|
@@ -261,7 +259,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.string_value(high)) | ||
| self.update_editor() | ||
|
|
||
| def _convert_to_slider(self, value): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
@@ -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") | ||
|
|
||
|
|
@@ -111,7 +109,7 @@ def init(self, parent): | |
| fvalue = self.low | ||
| else: | ||
| try: | ||
| fvalue_text = self.format % fvalue | ||
| fvalue_text = self.string_value(fvalue) | ||
| except (ValueError, TypeError) as e: | ||
| fvalue_text = "" | ||
|
|
||
|
|
@@ -157,11 +155,11 @@ def init(self, parent): | |
|
|
||
| low_label = factory.low_label | ||
| if factory.low_name != "": | ||
| low_label = self.format % self.low | ||
| low_label = self.string_value(self.low) | ||
|
|
||
| high_label = factory.high_label | ||
| if factory.high_name != "": | ||
| high_label = self.format % self.high | ||
| high_label = self.string_value(self.high) | ||
|
|
||
| self._label_lo.SetLabel(low_label) | ||
| self._label_hi.SetLabel(high_label) | ||
|
|
@@ -191,7 +189,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.string_value(value)) | ||
| self.value = value | ||
| except TraitError: | ||
| pass | ||
|
|
@@ -253,7 +251,7 @@ def update_editor(self): | |
| """ | ||
| value = self.value | ||
| try: | ||
| text = self.format % value | ||
| text = self.string_value(value) | ||
| 1 // (self.low <= value <= self.high) | ||
| except: | ||
| text = "" | ||
|
|
@@ -296,7 +294,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.string_value(low)) | ||
| self.update_editor() | ||
|
|
||
| def _high_changed(self, high): | ||
|
|
@@ -307,7 +305,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.string_value(high)) | ||
| self.update_editor() | ||
|
|
||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.